{"id":"3be53497-3071-4ebd-be20-ef93e85e4c30","shortId":"83bbb9","kind":"skill","title":"coding-style","tagline":"Coding style guidelines for C and POSIX code, covering layout, formatting, declarations, headers, and consistency expectations.","description":"Style\n=====\nNote that the following are guidelines and the most important aspect of style\nis consistency. Strive to keep your style consistent with the project on which\nyou are working. It is up to the project maintainer to take some liberty in the\nstyle **guidelines**.\n\n\nRecommended Reading\n-------------------\nThe following contain good information, some of which is repeated below, some\nof which is contradicted below.\n\n* <https://man.openbsd.org/style>\n* <http://doc.cat-v.org/bell_labs/pikestyle>\n* <https://www.kernel.org/doc/Documentation/process/coding-style.rst>\n\n\nFile Layout\n-----------\n* Comment with LICENSE and possibly short explanation of file/tool.\n* Headers\n* Macros\n* Types\n* Function declarations:\n  * Include variable names.\n  * For short files these can be left out.\n  * Group/order in logical manner.\n* Global variables.\n* Function definitions in same order as declarations.\n* `main`\n\n\nC Features\n----------\n* Use C99 without extensions (ISO/IEC 9899:1999).\n* Use POSIX.1-2008:\n  * When using gcc define `_POSIX_C_SOURCE 200809L`.\n  * Alternatively define `_XOPEN_SOURCE 700`.\n* Do not mix declarations and code.\n* Do not use for loop initial declarations.\n* Use `/* */` for comments, not `//`.\n* Variadic macros are acceptable, but remember:\n  * `__VA_ARGS__` not a named parameter.\n  * Arg list cannot be empty.\n\n\nBlocks\n------\n* All variable declarations at top of block.\n* `{` on same line preceded by single space (except functions).\n* `}` on own line unless continuing statement (`if else`, `do while`, ...).\n\nUse block for single statement if inner statement needs a block.\n\n\tfor (;;) {\n\t\tif (foo) {\n\t\t\tbar;\n\t\t\tbaz;\n\t\t}\n\t}\n\nUse block if another branch of the same statement needs a block:\n\n\tif (foo) {\n\t\tbar;\n\t} else {\n\t\tbaz;\n\t\tqux;\n\t}\n\n\nLeading Whitespace\n------------------\nUse tabs for indentation and spaces for alignment. This ensures everything will\nline up independent of tab size. This means:\n\n* No tabs except beginning of line.\n* Use spaces - not tabs - for multiline macros as the indentation level is 0,\n  where the `#define` began.\n\n\nFunctions\n---------\n* Return type and modifiers on own line.\n* Function name and argument list on next line. This allows to grep for function\n  names simply using `grep ^functionname(`.\n* Opening `{` on own line (function definitions are a special case of blocks as\n  they cannot be nested).\n* Functions not used outside translation unit should be declared and defined\n  `static`.\n\nExample:\n\n\tstatic void\n\tusage(void)\n\t{\n\t\teprintf(\"usage: %s [file ...]\\n\", argv0);\n\t}\n\n\nVariables\n---------\n* Global variables not used outside translation unit should be declared `static`.\n* In declaration of pointers the `*` is adjacent to variable name, not type.\n\n\nKeywords\n--------\n* Use a space after `if`, `for`, `while`, `switch` (they are not function calls).\n* Do not use a space after the opening `(` and before the closing `)`.\n* Preferably use `()` with `sizeof`.\n* Do not use a space with `sizeof()`.\n\n\nSwitch\n------\n* Do not indent cases another level.\n* Comment cases that FALLTHROUGH.\n\nExample:\n\n\tswitch (value) {\n\tcase 0: /* FALLTHROUGH */\n\tcase 1:\n\tcase 2:\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\nHeaders\n-------\n* Place system/libc headers first in alphabetical order.\n  * If headers must be included in a specific order add a comment to explain.\n* Place local headers after an empty line.\n* When writing and using local headers.\n  * Try to avoid cyclic header inclusion dependencies.\n  * Instead ensure they are included where and when they are needed.\n  * Read <https://talks.golang.org/2012/splash.article#TOC_5.>\n  * Read <http://plan9.io/sys/doc/comp.html>\n\n\nUser Defined Types\n------------------\n* Do not use `type_t` naming (it is reserved for POSIX and less readable).\n* Typedef opaque structs.\n* Do not typedef builtin types.\n* Use `CamelCase` for typedef'd types.\n\n\nLine Length\n-----------\n* Keep lines to reasonable length (max 79 characters).\n\n\nTests and Boolean Values\n------------------------\n* Do not use C99 `bool` types (stick to integer types).\n* Otherwise use compound assignment and tests unless the line grows too long:\n\n\tif (!(p = malloc(sizeof(*p))))\n\t\thcf();\n\n\nHandling Errors\n---------------\n* When functions `return -1` for error test against `0` not `-1`:\n\n\tif (func() < 0)\n\t\thcf();\n\n* Use `goto` to unwind and cleanup when necessary instead of multiple nested\n  levels.\n* `return` or `exit` early on failures instead of multiple nested levels.\n* Unreachable code should have a NOTREACHED comment.\n* Think long and hard on whether or not you should cleanup on fatal errors.\n  For simple \"one-shot\" programs (not daemons) it can be OK to not free memory.\n  It is advised to cleanup temporary files however.\n\n\nEnums and #define\n-----------------\nUse enums for values that are grouped semantically and #define otherwise:\n\n\t#define MAXSZ  4096\n\t#define MAGIC1 0xdeadbeef\n\n\tenum {\n\t\tDIRECTION_X,\n\t\tDIRECTION_Y,\n\t\tDIRECTION_Z\n\t};","tags":["coding","style","suckless","agent","skills","fuwn","agent-skills","bitreich"],"capabilities":["skill","source-fuwn","skill-coding-style","topic-agent-skills","topic-bitreich","topic-skills","topic-suckless"],"categories":["suckless-agent-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/Fuwn/suckless-agent-skills/coding-style","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add Fuwn/suckless-agent-skills","source_repo":"https://github.com/Fuwn/suckless-agent-skills","install_from":"skills.sh"}},"qualityScore":"0.459","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 18 github stars · SKILL.md body (4,923 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-23T01:02:09.725Z","embedding":null,"createdAt":"2026-04-18T23:07:06.753Z","updatedAt":"2026-04-23T01:02:09.725Z","lastSeenAt":"2026-04-23T01:02:09.725Z","tsv":"'-1':589,596 '/2012/splash.article#toc_5.':506 '/bell_labs/pikestyle':89 '/doc/documentation/process/coding-style.rst':92 '/style':86 '/sys/doc/comp.html':510 '0':293,441,594,599 '0xdeadbeef':689 '1':444 '1999':142 '2':446 '200809l':152 '4096':686 '700':157 '79':550 '9899':141 'accept':178 'add':467 'adjac':383 'advis':664 'align':262 'allow':315 'alphabet':456 'altern':153 'anoth':238,431 'arg':182,187 'argument':309 'argv0':364 'aspect':31 'assign':569 'avoid':487 'bar':233,249 'baz':234,251 'began':297 'begin':278 'block':192,199,220,229,236,246,336 'bool':560 'boolean':554 'branch':239 'break':447,449 'builtin':534 'c':8,134,150 'c99':137,559 'call':402 'camelcas':537 'cannot':189,339 'case':334,430,434,440,443,445 'charact':551 'cleanup':606,642,666 'close':414 'code':2,4,11,163,626 'coding-styl':1 'comment':95,173,433,469,631 'compound':568 'consist':18,35,41 'contain':69 'continu':213 'contradict':82 'cover':12 'cyclic':488 'd':540 'daemon':653 'declar':15,108,132,161,170,195,350,375,378 'default':448 'defin':148,154,296,352,512,672,682,684,687 'definit':127,330 'depend':491 'direct':691,693,695 'doc.cat-v.org':88 'doc.cat-v.org/bell_labs/pikestyle':87 'earli':617 'els':216,250 'empti':191,477 'ensur':264,493 'enum':670,674,690 'eprintf':359 'error':585,591,645 'everyth':265 'exampl':354,437 'except':207,277 'exit':616 'expect':19 'explain':471 'explan':101 'extens':139 'failur':619 'fallthrough':436,442 'fatal':644 'featur':135 'file':93,114,362,668 'file/tool':103 'first':454 'follow':24,68 'foo':232,248 'format':14 'free':660 'func':598 'function':107,126,208,298,306,319,329,342,401,587 'functionnam':324 'gcc':147 'global':124,366 'good':70 'goto':602 'grep':317,323 'group':679 'group/order':120 'grow':575 'guidelin':6,26,64 'handl':584 'hard':635 'hcf':583,600 'header':16,104,450,453,459,474,484,489 'howev':669 'import':30 'includ':109,462,496 'inclus':490 'indent':258,290,429 'independ':269 'inform':71 'initi':169 'inner':225 'instead':492,609,620 'integ':564 'iso/iec':140 'keep':38,544 'keyword':389 'layout':13,94 'lead':253 'left':118 'length':543,548 'less':526 'level':291,432,613,624 'liberti':60 'licens':97 'line':202,211,267,280,305,313,328,478,542,545,574 'list':188,310 'local':473,483 'logic':122 'long':577,633 'loop':168 'macro':105,176,287 'magic1':688 'main':133 'maintain':56 'malloc':580 'man.openbsd.org':85 'man.openbsd.org/style':84 'manner':123 'max':549 'maxsz':685 'mean':274 'memori':661 'mix':160 'modifi':302 'multilin':286 'multipl':611,622 'must':460 'n':363 'name':111,185,307,320,386,519 'necessari':608 'need':227,244,502 'nest':341,612,623 'next':312 'note':21 'notreach':630 'ok':657 'one':649 'one-shot':648 'opaqu':529 'open':325,410 'order':130,457,466 'otherwis':566,683 'outsid':345,370 'p':579,582 'paramet':186 'place':451,472 'plan9.io':509 'plan9.io/sys/doc/comp.html':508 'pointer':380 'posix':10,149,524 'posix.1-2008':144 'possibl':99 'preced':203 'prefer':415 'program':651 'project':44,55 'qux':252 'read':66,503,507 'readabl':527 'reason':547 'recommend':65 'rememb':180 'repeat':76 'reserv':522 'return':299,588,614 'semant':680 'short':100,113 'shot':650 'simpl':647 'simpli':321 'singl':205,222 'size':272 'sizeof':418,425,581 'skill' 'skill-coding-style' 'sourc':151,156 'source-fuwn' 'space':206,260,282,392,407,423 'special':333 'specif':465 'statement':214,223,226,243 'static':353,355,376 'stick':562 'strive':36 'struct':530 'style':3,5,20,33,40,63 'switch':397,426,438 'system/libc':452 'tab':256,271,276,284 'take':58 'talks.golang.org':505 'talks.golang.org/2012/splash.article#toc_5.':504 'temporari':667 'test':552,571,592 'think':632 'top':197 'topic-agent-skills' 'topic-bitreich' 'topic-skills' 'topic-suckless' 'translat':346,371 'tri':485 'type':106,300,388,513,517,535,541,561,565 'typedef':528,533,539 'unit':347,372 'unless':212,572 'unreach':625 'unwind':604 'usag':357,360 'use':136,143,146,166,171,219,235,255,281,322,344,369,390,405,416,421,482,516,536,558,567,601,673 'user':511 'va':181 'valu':439,555,676 'variabl':110,125,194,365,367,385 'variad':175 'void':356,358 'whether':637 'whitespac':254 'without':138 'work':49 'write':480 'www.kernel.org':91 'www.kernel.org/doc/documentation/process/coding-style.rst':90 'x':692 'xopen':155 'y':694 'z':696","prices":[{"id":"3f7b0e5d-f9fc-4ff4-beaf-a853e931514a","listingId":"3be53497-3071-4ebd-be20-ef93e85e4c30","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"Fuwn","category":"suckless-agent-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T23:07:06.753Z"}],"sources":[{"listingId":"3be53497-3071-4ebd-be20-ef93e85e4c30","source":"github","sourceId":"Fuwn/suckless-agent-skills/coding-style","sourceUrl":"https://github.com/Fuwn/suckless-agent-skills/tree/main/skills/coding-style","isPrimary":false,"firstSeenAt":"2026-04-18T23:07:06.753Z","lastSeenAt":"2026-04-23T01:02:09.725Z"}],"details":{"listingId":"3be53497-3071-4ebd-be20-ef93e85e4c30","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"Fuwn","slug":"coding-style","github":{"repo":"Fuwn/suckless-agent-skills","stars":18,"topics":["agent-skills","ai","bitreich","skills","suckless"],"license":"mit","html_url":"https://github.com/Fuwn/suckless-agent-skills","pushed_at":"2026-04-06T12:57:30Z","description":"🥤 Minimal agent skills grounded in the suckless philosophy","skill_md_sha":"177b6403d682c83f7b3fe69132bec4da02c540fb","skill_md_path":"skills/coding-style/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/Fuwn/suckless-agent-skills/tree/main/skills/coding-style"},"layout":"multi","source":"github","category":"suckless-agent-skills","frontmatter":{"name":"coding-style","description":"Coding style guidelines for C and POSIX code, covering layout, formatting, declarations, headers, and consistency expectations."},"skills_sh_url":"https://skills.sh/Fuwn/suckless-agent-skills/coding-style"},"updatedAt":"2026-04-23T01:02:09.725Z"}}