$npx -y skills add Varnan-Tech/opendirectory --skill claude-md-generatorUse when the user asks to generate or update a project's CLAUDE or AGENTS context file from a codebase scan. Writes a focused file under 100 lines containing only the non-obvious build commands, conventions, and gotchas Claude Code needs.
| 1 | # CLAUDE.md Generator |
| 2 | |
| 3 | Read the codebase. Write a CLAUDE.md that tells Claude exactly what it needs: no more, no less. |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | **Critical rule:** A good CLAUDE.md is under 100 lines. It contains only information Claude cannot derive from reading the code itself. Do not auto-write the file: always show the draft and wait for user approval first. |
| 8 | |
| 9 | **Code snippet rule:** Never include inline code examples in CLAUDE.md. Instead use `file.ts:42` references. Code in CLAUDE.md wastes tokens and goes stale. |
| 10 | |
| 11 | --- |
| 12 | |
| 13 | ## Step 1: Detect Mode |
| 14 | |
| 15 | Determine which of three modes to run: |
| 16 | |
| 17 | **create**: No CLAUDE.md exists. Write one from scratch. |
| 18 | **update**: A CLAUDE.md exists. Improve it without discarding custom content. |
| 19 | **audit**: Score all CLAUDE.md files in the project A-F and output a quality report. If the user says "audit", "check", "review", or "grade" my CLAUDE.md, run audit mode. |
| 20 | |
| 21 | ```bash |
| 22 | # Discover ALL CLAUDE.md locations |
| 23 | find . -name "CLAUDE.md" -not -path "*/node_modules/*" -not -path "*/.git/*" 2>/dev/null |
| 24 | ls ~/.claude/CLAUDE.md 2>/dev/null && echo "Global CLAUDE.md found" |
| 25 | ls .claude.local.md 2>/dev/null && echo ".claude.local.md found" |
| 26 | ``` |
| 27 | |
| 28 | If multiple CLAUDE.md files are found: list them. Ask: "Found CLAUDE.md in [locations]. Should I update all of them or just [root]?" |
| 29 | |
| 30 | --- |
| 31 | |
| 32 | ## Step 2: Audit Mode (skip to Step 3 if create/update) |
| 33 | |
| 34 | For each CLAUDE.md found, score it A-F using this rubric: |
| 35 | |
| 36 | | Criterion | What to check | |
| 37 | |-----------|--------------| |
| 38 | | Commands | Build/test/lint commands present and runnable? | |
| 39 | | Architecture | Non-obvious structure explained? | |
| 40 | | Non-obvious patterns | Gotchas, generated files, env var order documented? | |
| 41 | | Conciseness | Under 100 lines? No obvious filler? | |
| 42 | | Currency | Commands still match current package.json/Makefile? | |
| 43 | | Actionability | Can a new contributor follow this without asking questions? | |
| 44 | |
| 45 | Score: 90-100 = A, 70-89 = B, 50-69 = C, 30-49 = D, 0-29 = F |
| 46 | |
| 47 | Present as a table: |
| 48 | |
| 49 | ``` |
| 50 | ## CLAUDE.md Audit Report |
| 51 | |
| 52 | | File | Score | Grade | Top Issues | |
| 53 | |------|-------|-------|-----------| |
| 54 | | ./CLAUDE.md | 72 | B | Missing gotchas section, test command outdated | |
| 55 | | ./packages/api/CLAUDE.md | 45 | D | No commands, 340 lines (too long), stale arch notes | |
| 56 | |
| 57 | **Overall: B (72/100)** |
| 58 | |
| 59 | Issues found: |
| 60 | - ./packages/api/CLAUDE.md: 340 lines: well over the 100-line target |
| 61 | - ./packages/api/CLAUDE.md: Test command references `jest` but package.json uses `vitest` |
| 62 | - ./CLAUDE.md: No Gotchas section: most valuable section is missing |
| 63 | ``` |
| 64 | |
| 65 | After the report, ask: "Want me to fix any of these? (all / just root / specify)" |
| 66 | |
| 67 | If user says yes, continue to Step 3 for each file they want fixed. |
| 68 | |
| 69 | --- |
| 70 | |
| 71 | ## Step 3: Scan Project Structure |
| 72 | |
| 73 | ```bash |
| 74 | # Project type and package manager |
| 75 | ls package.json yarn.lock pnpm-lock.yaml bun.lockb requirements.txt pyproject.toml Cargo.toml go.mod 2>/dev/null |
| 76 | |
| 77 | # Top-level directory structure |
| 78 | find . -maxdepth 2 -type d \ |
| 79 | | grep -v node_modules | grep -v .git | grep -v __pycache__ \ |
| 80 | | grep -v ".next" | grep -v dist | grep -v build | sort |
| 81 | ``` |
| 82 | |
| 83 | --- |
| 84 | |
| 85 | ## Step 4: Extract Build and Test Commands |
| 86 | |
| 87 | ```bash |
| 88 | # npm/yarn/pnpm/bun scripts |
| 89 | cat package.json 2>/dev/null \ |
| 90 | | python3 -c " |
| 91 | import sys, json |
| 92 | d = json.load(sys.stdin) |
| 93 | for name, cmd in d.get('scripts', {}).items(): |
| 94 | print(f'{name}: {cmd}') |
| 95 | " |
| 96 | |
| 97 | # Python, Go, Rust Makefiles |
| 98 | cat Makefile 2>/dev/null | grep -E "^[a-z].*:" | head -20 |
| 99 | |
| 100 | # Go |
| 101 | cat go.mod 2>/dev/null | head -5 |
| 102 | |
| 103 | # Rust |
| 104 | cat Cargo.toml 2>/dev/null | grep -E "^\[" | head -10 |
| 105 | ``` |
| 106 | |
| 107 | Identify the exact commands for: build, test (all), test (single file/name), dev server, lint/typecheck. Note any env vars required to run them. |
| 108 | |
| 109 | --- |
| 110 | |
| 111 | ## Step 5: Find Code Style and Gotchas |
| 112 | |
| 113 | ```bash |
| 114 | # Import aliases (most commonly missed) |
| 115 | python3 -c " |
| 116 | import json, sys |
| 117 | try: |
| 118 | d = json.load(open('tsconfig.json')) |
| 119 | paths = d.get('compilerOptions', {}).get('paths', {}) |
| 120 | if paths: print('Import aliases:', json.dumps(paths, indent=2)) |
| 121 | except: pass |
| 122 | " 2>/dev/null |
| 123 | |
| 124 | # Environment variables required |
| 125 | cat .env.example 2>/dev/null | grep -v "^#" | grep -v "^$" | head -20 |
| 126 | |
| 127 | # Auto-generated files (must not be edited) |
| 128 | find . -path "*/node_modules" -prune -o -name "*.ts" -print \ |
| 129 | | xargs grep -l "DO NOT EDIT\|@generated\|Generated by" 2>/dev/null | head -5 |
| 130 | |
| 131 | # Test setup requirements |
| 132 | cat jest.config.js jest.config.ts vitest.config.ts 2>/dev/null | head -30 |
| 133 | |
| 134 | # Database/migration setup |
| 135 | ls migrations/ prisma/ drizzle/ db/ 2>/dev/null |
| 136 | ``` |
| 137 | |
| 138 | **What counts as a Gotcha** (include these, skip everything else): |
| 139 | - Files that are auto-generated (must not edit) |
| 140 | - Env vars required BEFORE tests run |
| 141 | - Non-default import alias mappings |
| 142 | - Test commands that |