diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..07718fc --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,81 @@ +# CLAUDE.md — rules for all agents working on vfmt + +vfmt is a ruff-style Verilog/SystemVerilog formatter/linter in Rust. +Read `README.md` for architecture and `TODO.md` for the backlog before +doing anything. + +## Hard invariants (never break these) + +1. **Never corrupt code.** The formatter either produces verified-correct + output or emits the input unchanged with an error. No partial output. +2. **Idempotent.** `format(format(x)) == format(x)`, always. +3. **Comments are never dropped.** + +## Simplicity first + +- Prefer the boring, obvious implementation. If you're building an + abstraction for a second user that doesn't exist yet, stop. +- Standard library first. Adding a dependency requires a written + justification in the feature README. +- Small functions, descriptive names, shallow nesting. Code should be + readable top-to-bottom without jumping around. +- Match the style of the surrounding code (comment density, naming, + module layout). + +## Rust standards + +- `cargo fmt` clean, `cargo clippy --all-targets` clean (no `#[allow]` + without a comment explaining why), `cargo test` green — all three + before declaring any work finished. +- No `unwrap()`/`expect()`/`panic!` in library code paths; return + `Result`. Tests and `main.rs` argument handling may use them. +- Public items get a one-line doc comment. Doc comments say what/why, + not how. +- No `unsafe`. + +## Document-based development + +Every feature lives in `docs/features//README.md`. That +README is the single source of truth for the feature and must contain +these sections: + +```markdown +# +## Goal — one paragraph, what and why +## Assumptions — everything you assumed that isn't enforced by code +## Handshakes — interfaces/contracts with other modules: what you + consume from them, what you promise to them +## Status / TODO — checklist; keep current as you work +## Work log — dated entries by the dev agent: what was done, key + decisions, deviations from plan +## QA log — dated entries by the QA agent: what was verified, + how, and findings +## Review — reserved for the lead; do not write here +``` + +Rules: + +- **Dev agents**: create/update the feature README *as you work*, not at + the end. Finished TODOs get checked off in the same README. If you + change a handshake another module depends on, say so explicitly in + Handshakes and in the work log. +- **QA agents**: you verify, you don't redesign. Run the checks, try to + break the feature, record everything in the QA log. File concrete + findings (file:line, reproduction) — not opinions. Small unambiguous + fixes (typos, missing test assertion) you may fix directly and note it. +- **Review section** is written only by the lead agent after examining + the work. Respond to review comments by fixing and logging in the work + log, not by editing the Review section. + +## Workflow + +- Do **not** run `git commit` or `git push` — the lead reviews and + commits all work. +- Do not touch files outside your feature's stated scope. If you need a + change in another module, write it as a request in your README's + Handshakes section and stop. +- New behavior needs tests in the same change. Every formatter change + must keep the snapshot + idempotency suite green + (`cargo test -p vlog_formatter`). +- Update `TODO.md`: check items your feature completes (leave the item + text intact).