Issue 145
process: Automated guardrails while editing, at commit, in CI and at review
Back to our planOpen
ciprocesstoolingpriority: high
Type
process
Summary
Make the project's standards check themselves, at every stage, for every contributor:
- While an AI agent edits a file: the check runs right away and tells the agent what to fix.
- At every commit: the same checks run, for people and agents alike.
- On every pull request: the checks run as required GitHub checks.
- At review: the reviewing agent gets the same checklist automatically.
Written rules are easy to drift from; automated checks aren't.
Problem
- The standards (#142 architecture docs, #144 lean context, #138 skills) are written down, but only ESLint and type checks run automatically. Nothing checks:
- doc and skill size and format
- that rules files are path-scoped
- that pointer skills match their source
- that relative links in docs resolve
- Claude Code's docs call instructions "advisory" and hooks deterministic (https://code.claude.com/docs/en/best-practices, opens in a new tab).
- A
PostToolUsehook can run after every edit and feed errors back to the agent. Exit code 2 "shows stderr to Claude" (https://code.claude.com/docs/en/hooks, opens in a new tab). - Subagents can preload skills with a
skills:field (https://code.claude.com/docs/en/sub-agents, opens in a new tab). Today theqa-revieweragent doesn't preloadpr-review.
Proposed fix
scripts/check-agent-docs.mjs(Node, no new dependencies, unit-tested) fails when:- a Markdown file under
AGENTS.md,CLAUDE.md,docs/,.agents/or.claude/is over 250 lines (tighter caps per path, as set in #144); - a
SKILL.mdbreaks the Agent Skills spec (https://agentskills.io/specification, opens in a new tab):nameformat,name≠ folder, or a missing or too-longdescription; - a
.claude/rules/*.mdfile has nopaths:; - a
.claude/skills/*pointer doesn't match its.agents/skills/*source; - a relative link or anchor in these files doesn't resolve.
- a Markdown file under
- Before commit: lint-staged runs the checker on staged Markdown. ESLint, including the boundary rules from #130, already runs on staged code.
- While the agent works:
.claude/settings.jsongets aPostToolUsehook onEdit|Writethat runs ESLint on the edited code file, or the checker on the edited doc, and returns failures to the agent (exit 2). - In CI: a
Docs & agent contextjob on every PR. The owner adds it to the required checks in themainruleset (owner action). - At review:
.claude/agents/qa-reviewer.mdgetsskills: [pr-review], so every review starts with the checklist.pr-reviewgains an Architecture section (right module and layer, no duplicated rule, shared parts reused, tests for new rules, no Payload outsidedata/andcms/) and a Docs section (lean, no repeated content, links resolve).
- Change workflow: step 3, "check locally", adds
npm testandnpm run check:docs.
Not proposed: an AI review step in CI (for example a Claude GitHub Action). It needs a paid API key, so it's an owner decision.
Acceptance criteria
- Not done: Each of these fails
npm run check:docslocally, at pre-commit and in CI, and the PR shows it: a 251-line doc, a skill whosenamedoesn't match its folder, a rules file withoutpaths:, a broken relative link. - Not done: After an agent edits a
.tsfile with a lint error, the hook's message reaches the agent in the same session (shown in the PR). - Not done: The reviewer agent loads
pr-reviewwithout being told to. - Not done: The checker has unit tests.
- Not done: Policy change: the owner signs off explicitly, and adds the new required check.
Depends on
#144 (lean context), so the checker's caps match the new layout; #129 (tests). Process groundwork for #127.
Area
tooling, ci
Priority
high
Generated by Claude Code, opens in a new tab