agentleFS
hashiiiiihashiiiii/rules-for-ai/skills/hashiiiii-zig/SKILL.md

hashiiiii-zig

Skill10 starsChanged 3 months agoMITView on GitHub

Use when writing, editing, or reviewing Zig implementation, tests, build files, or CI.

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 7 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write the smallest implementation that preserves required behavior.

    line 8
  2. Very specific:

    Keep unit tests in the implementation file.

    line 12
  3. Distinctive:

    Ensure the test root references test files.

    line 14
  4. Very specific:

    Prefer concrete types, const, inferred .{...} literals, structs, enums, tagged unions, exhaustive switch statements, ordinary functions, …

    line 18
  5. Distinctive:

    Use file imports within a module and named imports across modules.

    line 19
  6. Very specific:

    Use defer for cleanup and errdefer for error returns.

    line 21
  7. Very specific:

    Use undefined only for storage initialized before reading.

    line 23
  8. Distinctive:

    Add or keep a test only when at least 80% confident it is necessary, based on user impact, regression risk, and overlap with existing tests.

    line 27
  9. Very specific:

    Use native test blocks and std.testing.

    line 28
  10. Distinctive:

    Keep each test self-contained with literal inputs and expected values.

    line 29
  11. Very specific:

    Keep build.zig direct; run unit and end-to-end tests with zig build test.

    line 42
  12. Distinctive:

    Keep test-only imports or generators out of consumer builds with a separate test module.

    line 43
  13. Very specific:

    Run zig fmt --check on changed Zig files and zig build test with the project toolchain.

    line 45
  14. Distinctive:

    Keep CI jobs focused on distinct risks.

    line 46

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Zig

Write the smallest implementation that preserves required behavior. Use the project's Zig version and check matching standard-library examples before choosing syntax or APIs.

Structure

  • Keep unit tests in the implementation file. Put end-to-end tests in root e2e/ and exercise public API flows.
  • Export libraries from src/root.zig and executables from src/main.zig.
  • Ensure the test root references test files; Zig does not discover every source file automatically.

Implementation

  • Prefer concrete types, const, inferred .{...} literals, structs, enums, tagged unions, exhaustive switch statements, ordinary functions, and runtime loops. Use comptime, inline, anytype, or reflection only when required.
  • Use file imports within a module and named imports across modules.
  • Propagate errors with try; use catch for recovery or translation. Reserve unreachable for proven invariants.
  • Use defer for cleanup and errdefer for error returns. A union-valued failure does not run errdefer.
  • Accept allocators explicitly. Make ownership clear, copy retained input when needed, and store resource owners by value unless a stable address is required.
  • Use undefined only for storage initialized before reading; cast only when inference or representation requires it.

Tests

  • Add or keep a test only when at least 80% confident it is necessary, based on user impact, regression risk, and overlap with existing tests. This threshold concerns necessity, not coverage.
  • Use native test blocks and std.testing; name and assert the public behavior under test, not private layout or dependency guarantees.
  • Keep each test self-contained with literal inputs and expected values. Avoid shared fixtures, computed expectations, and case tables that obscure the assertion.
  • Comment on why behavior matters. Use real dependencies; never use mocks or stubs.
  • For allocations, use std.testing.allocator and release owned resources with defer.
test "parse rejects duplicate modifiers" {
    // Duplicate modifiers can hide configuration mistakes.
    try std.testing.expectError(error.InvalidKey, KeySpec.parse("Ctrl+Ctrl+x"));
}

Build and CI

  • Keep build.zig direct; run unit and end-to-end tests with zig build test.
  • Keep test-only imports or generators out of consumer builds with a separate test module. After changing module wiring, build a real consumer and inspect its dependency steps.
  • List distributed source paths in build.zig.zon .paths, including e2e/ when used.
  • Run zig fmt --check on changed Zig files and zig build test with the project toolchain. Check Debug and ReleaseSafe when changing ownership or error paths.
  • Keep CI jobs focused on distinct risks; avoid duplicate push and pull-request runs for the same change.

References: Zig sources, Readable Test Code.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.