A Claude Code skill that extracts and enforces a codebase's tribal knowledge.
![]() |
![]() |
|---|---|
| Rules Browser β HARD/SOFT/PREF with violation locations | Service Scores β per-service consistency bars + cross-service drift |
![]() |
|
|---|---|
| Health Tab β zombie dependencies + architectural drift zones |
Every mature codebase has unwritten rules β naming conventions, error handling patterns, import styles, architectural decisions β that only experienced team members know. New developers (and AI assistants) violate these rules not out of incompetence, but because nobody wrote them down.
DNA Guardian captures those rules as a machine-readable profile and enforces them continuously.
| Command | Description |
|---|---|
/dna-scan |
Scan the codebase and extract conventions as a DNA profile |
/dna-check [path] |
Audit files against the DNA profile |
/dna-refactor [path] |
Auto-fix convention violations |
/dna-report |
Generate a project-wide health dashboard |
/dna-preview |
Render an interactive HTML visual report |
/dna-onboard |
Generate a new-developer briefing from the DNA |
/dna-diff |
Show how conventions have evolved since last scan |
/dna-guard [branch] |
Pre-merge gate β block HARD violations |
npx skills add mturac/codebase-dna-guardiannpm install -g codebase-dna-guardiangit clone https://github.com/mturac/codebase-dna-guardian# 1. Scan your project
/dna-scan
# 2. Check a file before merging
/dna-check src/services/payment.ts
# 3. See the health dashboard
/dna-report
# 4. Visual interactive report
/dna-preview
# 5. Guard a PR
/dna-guard feature/payment-refactor
After running /dna-scan, Claude Code will automatically consult the DNA before generating any new code in your project β no extra commands needed.
The scanner is surgical β it samples strategically:
- Config files (tsconfig, eslint, pyproject.toml, etc.)
- Entry points (main.ts, app.ts, server.py)
- One vertical slice of a typical feature (route β service β repository β test)
- Error handling samples
- Shared utilities
- Test files
From these ~20 files it extracts patterns across 8 categories: Naming, Architecture, Error Handling, Testing, Imports, Dependencies, API Contracts, Async Patterns.
Every rule has one of three tiers:
| Tier | Behaviour |
|---|---|
| π΄ HARD | Stop before generating violating code. Explain. Ask to confirm. |
| π‘ SOFT | Generate compliant code + add a brief footnote. |
| π’ PREF | Silently apply. No mention. |
Once a .claude/dna.md exists, Claude Code reads it before every code generation β you don't have to invoke the skill explicitly. The DNA is always active.
The scan writes to .claude/dna.md (single project) or .claude/dna/ (monorepo):
.claude/
dna/
root.md β shared rules
frontend.md β service-specific overrides
backend.md β service-specific overrides
cross-service.md β auto-generated divergence map
dna-history.md β audit trail of all changes
The scripts/ directory contains a React dashboard component that renders an interactive health report:
cd scripts && npm install && npm run devOr use /dna-preview inside Claude Code β it will bundle and serve the dashboard automatically.
Features:
- Animated consistency score ring
- Per-service consistency bars
- Rules browser with violation locations
- Zombie dependency tracker
- Architectural drift zones
- DNA evolution sparkline
DNA Guardian handles multi-service projects natively:
Wave 1: Root scan (shared config, CI, shared utils)
Wave 2: Per-service scan (one vertical slice per service)
Wave 3: Cross-comparison (diff patterns across services)
Wave 4: Classification (intentional divergence vs drift)
Services are detected by workspace config (pnpm-workspace.yaml, package.json workspaces, lerna.json, nx.json, turbo.json) or by presence of multiple manifests at depth 2.
𧬠DNA-A2 (HARD): This project uses the Repository pattern β controllers
call services, services call repositories, repositories talk to the DB.
Direct DB access in a controller would break the architectural layering.
I'll create a repository method and wire it through the service layer instead.
Note: Named as `payment-service.ts` following DNA-N1 (kebab-case file naming).
Uses dayjs instead of moment because DNA-D2 says so. No mention.
πΉπ· TΓΌrkΓ§e Β· π«π· FranΓ§ais Β· π©πͺ Deutsch Β· π¨π³ δΈζ Β· π°π· νκ΅μ΄
See CONTRIBUTING.md. PRs welcome.
MIT Β© Mehmet Turac



