Skip to content

mturac/codebase-dna-guardian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧬 Codebase DNA Guardian

A Claude Code skill that extracts and enforces a codebase's tribal knowledge.

npm version License: MIT Claude Code skills.sh Install with npx

DNA Guardian Overview

Rules Services
Rules Browser β€” HARD/SOFT/PREF with violation locations Service Scores β€” per-service consistency bars + cross-service drift
Health
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.


✨ What it does

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

πŸš€ Installation

Recommended β€” skills.sh (one command, auto-updates)

npx skills add mturac/codebase-dna-guardian

Via npm

npm install -g codebase-dna-guardian

Manual

git clone https://github.com/mturac/codebase-dna-guardian

πŸ“– Quick Start

# 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.


πŸ— How it works

1. Scan (15–20 files, not the whole codebase)

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.

2. Severity tiers

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.

3. Passive Guardian Mode

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.


πŸ“ DNA Profile Format

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

πŸ“Š Visual Dashboard

The scripts/ directory contains a React dashboard component that renders an interactive health report:

cd scripts && npm install && npm run dev

Or 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

🧩 Monorepo Support

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.


πŸ”’ Severity Examples

HARD β€” stops code generation

🧬 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.

SOFT β€” footnote only

Note: Named as `payment-service.ts` following DNA-N1 (kebab-case file naming).

PREF β€” silent

Uses dayjs instead of moment because DNA-D2 says so. No mention.


🌍 Other Languages

πŸ‡ΉπŸ‡· TΓΌrkΓ§e Β· πŸ‡«πŸ‡· FranΓ§ais Β· πŸ‡©πŸ‡ͺ Deutsch Β· πŸ‡¨πŸ‡³ δΈ­ζ–‡ Β· πŸ‡°πŸ‡· ν•œκ΅­μ–΄


🀝 Contributing

See CONTRIBUTING.md. PRs welcome.


πŸ“œ License

MIT Β© Mehmet Turac

About

🧬 A Claude Code skill that extracts and enforces a codebase's tribal knowledge β€” naming conventions, architectural patterns, error handling strategies, and dependency choices.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors