Zen-C
Copilot instructions4.3k starsChanged 9 months agoMITView on GitHub
These instructions are MANDATORY for all code generation and review tasks in the Zen C project.
We split this copilot-instructions.md into the rules it gives an agent
18 rules. About 0 are common, 1 is distinctive, and 17 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Do NOT attempt to free AST nodes or types.
- Very specific: line 15
Creation: Use ast_create(NODE_TYPE) to allocate new nodes.
- Very specific: line 17
Use Type struct (defined in src/ast/ast.h).
- Distinctive: line 22
Do NOT introduce Visitor patterns or callback tables unless consistent with existing code.
- Very specific: line 28
Use expect(lexer, TOKEN_TYPE, "error message") for mandatory tokens.
- Very specific: line 35
Every error path that returns NULL/an error node must already have emitted a diagnostic.
- Very specific: line 36
Symbol Mangling: use the canonical mangle_method_symbol(base, trait, method) (see docs/CONTRIBUTING for the rule).
- Very specific: line 41
Fallback: If the mangled struct (e.g.
- Very specific: line 44
Use emit_func_signature(ctx, out, node, override_name) to handle modifiers, return types, and arguments correctly.
- Very specific: line 45
Output: Use fprintf(out, ...) where out is the FILE*.
- Very specific: line 58
When implementing iteration in compiler (C code): Use while (node) { ...
- Very specific: line 61
Arrays: Use for val in arr syntax (direct iteration).
- Very specific: line 76
Defer: Use defer stmt; to run cleanup at scope exit.
- Very specific: line 79
Iteration: Use for val in arr (direct iteration supported).
- Very specific: line 84
Use async fn and await keyword.
- Very specific: line 87
Import with import "std/io.zc", import "std/vec.zc".
- Very specific: line 88
Use println "msg" (shorthand) or printf.
- Very specific: line 90
Use test "name" { ... } blocks for unit tests.
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Zen C Copilot Instructions
These instructions are MANDATORY for all code generation and review tasks in the Zen C project.
1. Memory Management (Critical)
- Arena Allocation: The compiler uses a bump-pointer arena allocator.
- MUST USE:
xmalloc,xcalloc,xrealloc,xstrdup(defined insrc/utils/utils.c). - NEVER USE: Standard
malloc,calloc,free(unless interfacing with an external library that strictly requires owned heap memory, like CJSON).
- MUST USE:
- Destructors/Freeing:
free(ptr)is#definedto((void)0)insrc/zprep.h. It is a no-op.- Do NOT attempt to free AST nodes or types.
ast_freeis a no-op. - Memory is reclaimed only when the process exits. Design your data structures accordingly (append-only is fine).
2. AST and Type System
- Creation: Use
ast_create(NODE_TYPE)to allocate new nodes. - Type Representation:
- Use
Typestruct (defined insrc/ast/ast.h). - Use
type_new(TYPE_KIND)helper. type_to_string(t)andtype_to_c_string(t)return arena-allocated strings. Do not worry about freeing them.
- Use
- Traversal:
- The compiler uses Recursive Descent with Switch Statements on
node->kind. - Do NOT introduce Visitor patterns or callback tables unless consistent with existing code.
- The compiler uses Recursive Descent with Switch Statements on
3. Parser Patterns
- Context:
ParserContext *ctxis the god-object. It MUST be passed to almost every function in parsing, analysis, and codegen.- Signature Rule:
ReturnType func_name(ParserContext *ctx, ...)
- Signature Rule:
- Token Consumption:
- Use
expect(lexer, TOKEN_TYPE, "error message")for mandatory tokens. - For optional tokens, check
l->token.kindand assumelexer_next(l)is used to advance (verify specific helper availability).
- Use
- Error Handling:
- Fatal / syntax:
zpanic_at(token, "…"). Exits immediately (or delegates to the LSP handler in fault-tolerant mode). "Expected …" errors use this. - Warning:
zwarn_at(token, "…"). - Recoverable (parser):
zerror_at(token, "…")— only for conditions parsing can proceed past (e.g. MISRA guidance), not malformed syntax. - Semantic (typechecker):
tc_error(tc, token, "…"). - Every error path that returns
NULL/an error node must already have emitted a diagnostic.
- Fatal / syntax:
- Symbol Mangling: use the canonical
mangle_method_symbol(base, trait, method)(seedocs/CONTRIBUTING for the rule); never re-implement%s__%s+merge_underscoresinline.
4. Code Generation (C Backend)
- Generic Mangling:
- Generic structs (e.g.,
Slice<int>) are mangled toSlice_intIF AND ONLY IF the instantiated struct exists (checked viafind_struct_def_codegen). - Fallback: If the mangled struct (e.g.
Async_int) does not exist, use the base name (Async). This handles opaque types likeAsync<T>correctly. - See
emit_c_declinsrc/codegen/codegen_utils.cfor the canonical implementation.
- Generic structs (e.g.,
- Function Signatures:
- Use
emit_func_signature(ctx, out, node, override_name)to handle modifiers, return types, and arguments correctly.
- Use
- Output: Use
fprintf(out, ...)whereoutis theFILE*.
5. Coding Style & Conventions
- Formatting:
- Indentation: 4 spaces.
- Braces: ALWAYS Use braces
{}for control flow (if,while,for), even for single lines. - Opening brace on the NEXT line (Allman style).
- Naming:
- Structs/Enums:
PascalCase. - Functions/Variables:
snake_case. - Macros/Constants:
SCREAMING_SNAKE_CASE. - Private/Static: No strict prefix, but
statickeyword is mandatory for internal file-scope functions.
- Structs/Enums:
- Iterators:
- When implementing iteration in compiler (C code): Use
while (node) { ... node = node->next; }for linked lists (ASTNode,StructRef).
- When implementing iteration in compiler (C code): Use
6. Standard Library (Zen C Definitions)
- Arrays: Use
for val in arrsyntax (direct iteration). - Vectors:
Vec<T>is a dynamic array. - Strings:
stringin Zen C maps tochar*in C.kstringorzstrare higher-level wrappers.
7. Common Pitfalls
- Unused Variables: The compiler builds with
-Wall -Werror(or similar strictness). Cast unused vars to void:(void)var_name;.
8. Zen C Language Rules (For writing .zc files)
- Syntax:
- Variables:
let x = 10;,let y: const int = 20;. - Constants:
def MAX = 100;(compile-time). - Functions:
fn name(arg: type) -> ret { ... }. - Structs:
struct Point { x: int; y: int; }. - Enums:
enum Shape { Circle(float), Rect(float, float) }.
- Variables:
- Memory & Resources:
- Move Semantics: Structs/Enums are moved by default on assignment/pass-by-value.
- Defer: Use
defer stmt;to run cleanup at scope exit. - Drop: Implement
impl Drop for Tfor RAII.
- Arrays & Slices:
- Iteration: Use
for val in arr(direct iteration supported). - Slices:
Slice<T>is a view.int[N]auto-converts to slice in loops.
- Iteration: Use
- Generics:
- Syntax:
struct Box<T> { val: T; }.
- Syntax:
- Concurrency:
- Use
async fnandawaitkeyword. Async<T>is the opaque future type.
- Use
- Standard Library:
- Import with
import "std/io.zc",import "std/vec.zc". - Use
println "msg"(shorthand) orprintf.
- Import with
- Testing:
- Use
test "name" { ... }blocks for unit tests.
- Use
Trending
Quiet since March.about the whole repository
Who's talking about z-libs/Zen-C
- A Hacker News story“Zen-C: Write like a high-level language, run like C”Hacker News · Jan 12, 2026 · 214 points
- @nel.pet“ha- haha. ha”Bluesky · Jan 23, 2026 · 5 likes
- Zuhaitz-dev/zenc-lang“CMake support”GitHub · Jan 12, 2026 · 2 reactions
- @sungkim.bsky.social“and manual memory management with RAII capabilities, all while maintaining 100% C ABI compatibility." …”Bluesky · Jan 12, 2026 · 2 likes
- @hn100.bsky.social“Zen-C: Write like a high-level language, run like C Discussion”Bluesky · Jan 12, 2026 · 2 likes
The biggest 5 of 31 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 31
Talked about on GitHub, Bluesky and Hacker News (31 times).
On GitHub · 23
- Jan 12, 2026CMake support — Zuhaitz-dev/zenc-lang2 reactions · 1 comment
- Mar 15, 2026clean: remove the compiler outputs — Zuhaitz-dev/zenc-lang0 reactions
- Mar 15, 2026binary files checked in by mistake? — Zuhaitz-dev/zenc-lang0 reactions
- Mar 14, 2026Debugging support for Zen C source code — Zuhaitz-dev/zenc-lang0 reactions · 2 comments
- Mar 14, 2026Enable breakpoints in Zen C files — zenc-lang/vscode-zenc0 reactions
18 more on GitHub
- Mar 7, 2026zen-c — getsolus/packages0 reactions
- Mar 6, 2026Support selective unit tests instead of always running all tests; fix issue 283 — Zuhaitz-dev/zenc-lang0 reactions
- Mar 6, 2026[BUG] make test doesn't clean up transpilation output anymore — Zuhaitz-dev/zenc-lang0 reactions · 2 comments
- Mar 5, 2026Fix issue 280 — Zuhaitz-dev/zenc-lang0 reactions · 2 comments
- Feb 28, 2026Fix issue #260 — Zuhaitz-dev/zenc-lang0 reactions · 1 comment
- Feb 13, 2026[Website] Example is outdated — Zuhaitz-dev/zenc-lang0 reactions · 2 comments
- Feb 9, 2026Remove '_lmaginary' ('L' + 'maginary') from C reserved-keywords list — Zuhaitz-dev/zenc-lang0 reactions · 1 comment
- Feb 9, 2026Updated highlighting of numeric literals to be more comprehensive — zenc-lang/zenc.vim0 reactions
- Feb 9, 2026Comprehensive numeric literal support — Zuhaitz-dev/zenc-lang0 reactions · 4 comments
- Feb 8, 2026codegen warnings during build — Zuhaitz-dev/zenc-lang0 reactions · 1 comment
- Feb 8, 2026New typechecker is a breaking change - code and examples with ffi are broken — Zuhaitz-dev/zenc-lang0 reactions · 1 comment
- Feb 7, 2026Add type qualifier to numeric literal highlighting — zenc-lang/zenc.vim0 reactions
- Jan 25, 2026fix(parser_expr): lambda block syntax "fn" — Zuhaitz-dev/zenc-lang0 reactions
- Jan 20, 2026reference binding for enum in pattern-matching "match" not working — Zuhaitz-dev/zenc-lang0 reactions · 2 comments
- Jan 14, 2026Add Zen-C — ChessMax/awesome-programming-languages0 reactions
- Jan 13, 202627 : Remove unused label_counter parameter from emit_match_logic — Zuhaitz-dev/zenc-lang0 reactions
- Jan 12, 2026Suggestion: write error messages from the library to stderr — Zuhaitz-dev/zenc-lang0 reactions · 1 comment
- Jan 12, 2026zen-c — nanovms/ops-examples0 reactions · 1 comment
On Bluesky · 7
- Jan 23, 2026ha- haha. ha — @nel.pet5 likes and reposts
- Jan 12, 2026and manual memory management with RAII capabilities, all while maintaining 100% C ABI compatibility." github.com/z-libs/Zen-C — @sungkim.bsky.socialsays it tested it2 likes and reposts
- Jan 12, 2026Zen-C: Write like a high-level language, run like C Discussion — @hn100.bsky.social2 likes and reposts
- Feb 6, 2026Zen C: a strictly typed systems Language that brings pattern matching, traits, and ownership semantics to the C ecosystem. The syntax and… — @lcheylus.bsky.social1 likes and repost
- Jan 12, 2026Zen-C: Write like a high-level language, run like C https://github.com/z-libs/Zen-C (https://news.ycombinator.com/item?id=46587804) — @betterhn50.e-work.xyz1 likes and repost
2 more on Bluesky
- Jan 12, 2026Zen-C: Write like a high-level language, run like C https://github.com/z-libs/Zen-C (https://news.ycombinator.com/item?id=46587804) — @betterhn20.e-work.xyz1 likes and repost
- Jan 27, 2026This project is neat. — @mierau.me0 likes and reposts · 1 reply
On Hacker News · 1
- Jan 12, 2026Zen-C: Write like a high-level language, run like C214 points · 147 comments
Other versions1 project uses a version of this.
Word for word · 1
- zenc-lang/zenc★ 4.3k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

