Claude Code Best Practices
Lessons learned from the March 2026 sprint. These apply to all developers using Claude Code on SecurityV0 repos.
Cross-File Reference Tracing
After ANY type, interface, field, or function change -- trace ALL references before committing.
The checklist:
grep -rn "old_name" src/ ui/src/ test/-- find every referencenpx tsc --noEmit-- backend typecheckcd ui && npx tsc --noEmit-- frontend typechecknpx vitest run test/<affected>.test.ts-- targeted testsgit diff --stat-- review every changed file
Why: Removing a field from a type but leaving references in UI forms, API routes, and test fixtures causes multiple review rounds. A single grep catches them all.
Simplicity-First Design
Start with the simplest model that works. Don't add optional fields, extra statuses, or secondary levels unless there's a current user need.
Example: The ownership assignment model went through 6 review rounds because it started with level (primary/secondary), effective_until, and expired status. The correct Phase 1 model was: one owner per target, active or revoked.
Rule: Before adding an optional field, ask: "Does any current user flow need this?" If no, omit it.
Full-Stack Verification
Every change that touches types must verify both backend AND frontend:
- Backend:
npx tsc --noEmitfrom repo root - Frontend:
cd ui && npx tsc --noEmit - Tests:
npx vitest run(not just targeted files)
Running only one typecheck misses cross-boundary issues.
Environment URLs
| Environment | URL |
|---|---|
| Production | app.securityv0.com |
| Dev (main branch) | dev.securityv0.com |
| PR previews | pr-N.dev.securityv0.com |
| Visual reviews | pr-N.sv0-reviews.pages.dev |
| Sprint reviews | sprint-<name>.sv0-reviews.pages.dev |
| Documentation | sv0-docs.pages.dev |
Never use localhost for sprint reviews, stakeholder reviews, or QA reports. Always compare deployed environments.
Sprint Review Workflow
Always use the sprint review skill (sv0-skills/sprint-review/SKILL.md). Never generate a simple visual diff and call it a sprint review.
The skill orchestrates: action plan parsing, screenshot mapping, GitHub status collection, verdict derivation, HTML rendering, Cloudflare deployment.
Key files:
- Action plan:
sv0-documentation/docs/product/reviews/march-2026-platform-review/2026-03-21-consolidated-action-plan.md - Mapping:
sv0-skills/sprint-review/screenshot-mapping.yaml - GitHub config:
sv0-skills/sprint-review/github-query-march-2026.yaml - Snapshots:
sv0-intelligence/store/snapshots/
Docusaurus Link Format
Links in generated reports must use absolute URLs with the /docs/ prefix:
https://sv0-docs.pages.dev/docs/path/to/page
Not relative .md paths (those only work in Obsidian). No .md extension in URLs.
Sub-Agent Discipline
From .claude/rules/workflow.md:
- Max 4 parallel agents per wave
- Agents MUST push their branches
- Agents MUST verify their branch before committing
- Cross-review BEFORE merge, not after
- Clean up worktrees after each wave
Codex Review Integration
When using Codex for code review:
- Don't fix only the flagged line -- audit the ENTIRE feature for the same pattern
- After each fix round, run the full verification checklist (grep + tsc + tests)
- If a fix introduces a new field/type change, trace all consumers before pushing
Git Safety
The platform .claude/settings.json denies:
- Pushing to
mainordevdirectly - Force pushing
git merge(rebase workflow only)git reset --hard,rm -rfgh pr merge(manual merge only)
Always create a feature branch and PR. Always verify your branch with git branch --show-current before committing.
Common Pitfalls
- Forgetting UI typecheck -- Backend compiles but UI has type errors. Always run both.
- Stale worktrees -- Accumulate during review cycles. Clean with
git worktree pruneafter each PR. - Test mocks out of sync -- Adding StorageAdapter methods requires updating ALL
Partial<StorageAdapter>mocks. Find them:grep -rn "Partial<StorageAdapter>" test/ - Generated files manually edited -- Sprint reviews, reports, evidence packs are generated. Put overrides in config (e.g.,
verdict_overridein screenshot-mapping.yaml), not in the output. - Relative links in HTML output -- Markdown relative links work in Obsidian but break in deployed HTML. Use absolute Docusaurus URLs.
- Branch confusion -- Too many local branches without verifying current branch. Always run
git branch --show-currentbefore making changes. Use worktrees instead of branch switching. - CI failures discovered one at a time -- Run
npm run ci && cd ui && npm run cilocally before any PR. Catches lint + typecheck + all tests + build in one shot. - YAML parser format mismatch -- When building parsers for config files, always include an integration test that loads the actual file. Don't just test against synthetic inputs.