com um clique
zireael-code-style
// Write readable C with proper comments, named constants, and consistent style per CODE_STANDARDS.md.
// Write readable C with proper comments, named constants, and consistent style per CODE_STANDARDS.md.
Review C code for compliance with Zireael standards. Use before committing or when reviewing PRs.
Write readable C with proper comments, named constants, and consistent style per CODE_STANDARDS.md.
Enforce locked docs, boundary rules, and safety guardrails for any Zireael change.
Write readable C with proper comments, named constants, and consistent style per CODE_STANDARDS.md.
Maintain stable C ABI and versioned binary formats (drawlist + event batches).
Maintain portable CMake builds and deterministic unit/golden/fuzz/integration tests.
| name | zireael-code-style |
| description | Write readable C with proper comments, named constants, and consistent style per CODE_STANDARDS.md. |
| metadata | {"short-description":"Code style + comments + constants"} |
Use this skill when:
docs/CODE_STANDARDS.md — naming, comments, function size, ownership docsdocs/SAFETY_RULESET.md — safety and determinism rulesdocs/LIBC_POLICY.md — allowed/forbidden libc functionsEvery .c/.h file MUST start with:
/*
path/to/file.c — Brief description (one line).
Why: Explain the purpose and key design decisions.
*/
MUST have a function-level comment when:
DO NOT need function-level comment:
zr_rgb_r(), zr_style_default())Add comments inside functions for:
Do NOT add comments that:
/* increment i */ i++)/*
* Ring buffer layout:
*
* Case 1: tail >= head
* [....head=====tail....]
*
* Case 2: tail < head (wrapped)
* [====tail......head====]
*/
/* --- Validate inputs --- */
...
/* --- Process data --- */
...
/* --- Write outputs --- */
/* RGB stored as 0x00RRGGBB */
/* Ensures offset + size doesn't overflow before pointer creation */
When expressions combine shifts, masks, chained ternaries, or multiple fallbacks:
/* AVOID */
g.bytes[0] = (uint8_t)(ZR_UTF8_3BYTE_LEAD | ((cp >> 12u) & ZR_UTF8_3BYTE_MASK));
/* PREFERRED */
const uint8_t cp_top4 = zr_utf8_bits(cp, 12u, ZR_UTF8_3BYTE_MASK);
g.bytes[0] = zr_utf8_make_lead(ZR_UTF8_3BYTE_LEAD, cp_top4);
Extract magic numbers to named constants:
/* BAD */
if (align > 4096u) return false;
/* GOOD */
#define ZR_ARENA_MAX_ALIGN 4096u
if (align > ZR_ARENA_MAX_ALIGN) return false;
Group related constants with section comments:
/* --- SGR (Select Graphic Rendition) codes --- */
#define ZR_SGR_RESET 0u
#define ZR_SGR_BOLD 1u
#define ZR_SGR_ITALIC 3u
Use !ptr consistently:
/* GOOD */
if (!ptr) return ZR_ERR_INVALID_ARGUMENT;
/* AVOID */
if (ptr == NULL) return ZR_ERR_INVALID_ARGUMENT;
| Type | Convention | Example |
|---|---|---|
| Functions | module_action_noun() | arena_alloc_aligned() |
| Variables | snake_case descriptive | bytes_remaining |
| Constants | ZR_MODULE_NAME | ZR_DL_MAGIC |
| Types | zr_name_t | zr_arena_t |
Before finalizing code:
!ptr style