# AGENTS.md — C

Drop this in your repository root and symlink CLAUDE.md to it:

    ln -s AGENTS.md CLAUDE.md

Then delete every line that is not true of YOUR repository, and add the
corrections you have had to make to an agent twice. Under 100 lines is the
target — every line competes for attention with every other line.

From C at https://learn-c.net/ai/ — free to use, MIT.

---

C17, clang. Sanitizers are on in the debug build and that is the default.

## Commands
- Build:  `make debug`  (-fsanitize=address,undefined -g -O1 + full warnings)
- Test:   `make check`  (sanitized run + clang-tidy + cppcheck)
- Fuzz:   `make fuzz`   (any parser touching untrusted bytes)

## Flags that must stay on
-Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wformat=2 -Wformat-security
-D_FORTIFY_SOURCE=3 -fstack-protector-strong
-fsanitize=address,undefined

## Conventions
- Check every allocation. malloc/calloc/realloc results are used only after
  a NULL check.
- calloc(n, size), never malloc(n * size) — the multiplication can overflow.
- snprintf, never sprintf/strcpy/strcat/gets. Always pass sizeof the dest.
- size_t for sizes and indices, never int.
- realloc into a temporary, check, then reassign.
- Single cleanup path per function: goto cleanup, one free per allocation.
- Never return a pointer to a local.
- Signed overflow is undefined: use __builtin_*_overflow.

## Review
Any new parser of external input gets a fuzz target in the same commit.
