--- name: alignment description: Review staged or uncommitted code to ensure quality, test coverage, and alignment with project specifications disable-model-invocation: true --- # Code Alignment Review staged or uncommitted code to ensure quality, test coverage, and alignment with the project's spec (`docs/spec/`) and architecture playbook (`docs/architecture/`). This skill is also executed by a **clean-context subagent** at session wrap-up (see CLAUDE.md → Session wrap-up protocol). When running as that subagent: you deliberately have no session context — judge the diff against the written contracts only, and return the summary (rule #18) as your final message so the session agent can relay it. If a change looks deliberate but its rationale is recorded nowhere, that absence is itself a finding. ## Scope Determine the review scope using `git diff` (unstaged) and `git diff --staged` (staged). Review all changes in scope. If changes span multiple patterns below, apply all relevant sections. ## General Instructions ### Process 1. **Git**: **NEVER** stage (`git add`) or commit (`git commit`) — that is the USER's responsibility. If the reviewed changes span multiple independent concerns (a feature + an unrelated fix, a refactor + a new capability), suggest splitting them into separate commits and mention the logical boundaries. 2. **Verification**: After changes, run `npm run typecheck` and `npm test`; run `npm run build` if the change could affect the build. If tests fail, fix the issue if straightforward; ask the user only if non-trivial or ambiguous. 3. **Fix directly; don't ask first.** When you find an issue covered by these instructions, fix it in place rather than reporting it and waiting. Ask the user only when the fix is genuinely ambiguous or several valid approaches exist with real trade-offs. When guidelines conflict, prefer in this order: **SOUL.md philosophy > `docs/spec/` behavioral record > `docs/architecture/` patterns > local cleanup**. (The spec is descriptive — the code leads. A spec/code mismatch is fixed by updating the stale spec section, not by reverting the code; only flag the code when it contradicts recorded _rationale_, not merely an unrewritten section.) These instructions are not strictly prohibitive — if a guideline has a valid reason to be bypassed, mention it in the summary. ### Code Quality 4. **Code Cleanup**: Remove leftover code, unnecessary defensive programming, and over-engineering from iterative development — dead code, try/catch around internal calls that can't throw, abstraction layers wrapping a single implementation. Proceed with caution; ask if unsure. - **Export hygiene**: a symbol is exported only if another module imports it. Symbols used only within their module (including `as const` arrays that exist to derive a type) stay unexported — `export type` the type, not its source array. Verify with Grep before exporting "for future use"; the future caller can add the export. 5. **Styles and UI**: When altering CSS or layout, follow or generalize existing patterns (CSS Modules + design tokens in `styles/tokens.css`) rather than writing from scratch. Don't fix whitespace/formatting (trailing newlines etc.) — Prettier owns that. - **Control primitives & the two-height scale** (arch 09 §4): action buttons are the `Button` component, icon-only buttons are `IconButton` — never a freshly styled `