claudenv 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -104
- package/bin/cli.js +69 -8
- package/package.json +8 -8
- package/scaffold/global/.claude/commands/claudenv.md +150 -0
- package/scaffold/global/.claude/skills/claudenv/SKILL.md +49 -0
- package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/agents/doc-analyzer.md +70 -0
- package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/commands/init-docs.md +69 -0
- package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/commands/update-docs.md +49 -0
- package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/commands/validate-docs.md +40 -0
- package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/SKILL.md +56 -0
- package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/scripts/validate.sh +108 -0
- package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/templates/detection-patterns.md +76 -0
- package/scaffold/global/.claude/skills/claudenv/templates/detection-patterns.md +76 -0
- package/src/installer.js +109 -0
package/README.md
CHANGED
|
@@ -1,103 +1,77 @@
|
|
|
1
1
|
# claudenv
|
|
2
2
|
|
|
3
|
-
One command to set up [Claude Code](https://docs.anthropic.com/en/docs/claude-code)
|
|
3
|
+
One command to set up [Claude Code](https://docs.anthropic.com/en/docs/claude-code) in any project. Claude AI analyzes your codebase and generates all the documentation it needs to work effectively.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
Run directly without installing — pick your package manager:
|
|
5
|
+
## Quick Start
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
|
|
11
|
-
pnpm dlx claudenv # pnpm
|
|
12
|
-
bunx claudenv # bun
|
|
13
|
-
yarn dlx claudenv # yarn
|
|
8
|
+
npm i -g claudenv && claudenv
|
|
14
9
|
```
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
Done. Open Claude Code in any project and type `/claudenv`.
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
npm i -g claudenv
|
|
20
|
-
```
|
|
13
|
+
## How It Works
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
**One-time setup** — install and activate:
|
|
23
16
|
|
|
24
17
|
```bash
|
|
25
|
-
|
|
26
|
-
npx claudenv
|
|
18
|
+
npm i -g claudenv && claudenv
|
|
27
19
|
```
|
|
28
20
|
|
|
29
|
-
|
|
21
|
+
This installs the `/claudenv` command globally into `~/.claude/`, making it available in every project.
|
|
30
22
|
|
|
31
|
-
|
|
23
|
+
**In any project** — open Claude Code and type `/claudenv`.
|
|
32
24
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
Claude AI will:
|
|
26
|
+
1. Read your manifest files, configs, and source code
|
|
27
|
+
2. Detect your tech stack, frameworks, and tooling
|
|
28
|
+
3. Ask you about the project (description, deployment, conventions)
|
|
29
|
+
4. Generate all documentation files
|
|
30
|
+
5. Install slash commands for ongoing maintenance
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
**Step 3.** You now have three commands available in Claude Code:
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
### Option B: Slash command (auto-installed)
|
|
48
|
-
|
|
49
|
-
After running `claudenv` in your project, the `.claude/commands/init-docs.md` file is created. This gives you the `/init-docs` slash command inside Claude Code, which does the same thing — analyzes the project and generates documentation.
|
|
34
|
+
| Command | What it does |
|
|
35
|
+
|---------|-------------|
|
|
36
|
+
| `/init-docs` | Regenerate documentation from scratch |
|
|
37
|
+
| `/update-docs` | Scan for changes and propose updates |
|
|
38
|
+
| `/validate-docs` | Check that documentation is complete and correct |
|
|
50
39
|
|
|
51
|
-
## What
|
|
40
|
+
## What Gets Generated
|
|
52
41
|
|
|
53
42
|
```
|
|
54
43
|
your-project/
|
|
55
|
-
├── CLAUDE.md
|
|
56
|
-
├── _state.md
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
│
|
|
60
|
-
│
|
|
61
|
-
│
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
│
|
|
65
|
-
│
|
|
66
|
-
│
|
|
67
|
-
|
|
68
|
-
│
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
│ │ └── templates/detection-patterns.md
|
|
72
|
-
│ └── agents/
|
|
73
|
-
│ └── doc-analyzer.md # Read-only analysis subagent
|
|
44
|
+
├── CLAUDE.md # Project overview, commands, architecture
|
|
45
|
+
├── _state.md # Session memory (decisions, focus, issues)
|
|
46
|
+
└── .claude/
|
|
47
|
+
├── rules/
|
|
48
|
+
│ ├── code-style.md # Coding conventions (scoped by file paths)
|
|
49
|
+
│ ├── testing.md # Test patterns and commands
|
|
50
|
+
│ └── workflow.md # Claude Code best practices
|
|
51
|
+
├── settings.json # Validation hooks
|
|
52
|
+
├── commands/
|
|
53
|
+
│ ├── init-docs.md # /init-docs
|
|
54
|
+
│ ├── update-docs.md # /update-docs
|
|
55
|
+
│ └── validate-docs.md # /validate-docs
|
|
56
|
+
├── skills/
|
|
57
|
+
│ └── doc-generator/ # Auto-triggers when docs need updating
|
|
58
|
+
└── agents/
|
|
59
|
+
└── doc-analyzer.md # Read-only analysis subagent
|
|
74
60
|
```
|
|
75
61
|
|
|
76
|
-
### Key
|
|
62
|
+
### Key Files
|
|
77
63
|
|
|
78
64
|
| File | Purpose |
|
|
79
65
|
|------|---------|
|
|
80
|
-
| `CLAUDE.md` | Compact project overview
|
|
81
|
-
| `_state.md` |
|
|
82
|
-
| `.claude/rules/workflow.md` | Best practices: plan mode, `/compact`,
|
|
66
|
+
| `CLAUDE.md` | Compact project overview with `@import` references to rule files |
|
|
67
|
+
| `_state.md` | Persists context between sessions — current focus, decisions, known issues |
|
|
68
|
+
| `.claude/rules/workflow.md` | Best practices: plan mode, `/compact`, subagents, git discipline |
|
|
83
69
|
| `.claude/rules/code-style.md` | Language and framework-specific coding conventions |
|
|
84
70
|
| `.claude/rules/testing.md` | Test framework patterns and commands |
|
|
85
71
|
|
|
86
|
-
##
|
|
72
|
+
## Tech Stack Detection
|
|
87
73
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
| Command | What it does |
|
|
91
|
-
|---------|-------------|
|
|
92
|
-
| `/init-docs` | Re-run interactive documentation setup |
|
|
93
|
-
| `/update-docs` | Scan for changes and propose doc updates |
|
|
94
|
-
| `/validate-docs` | Check that documentation is complete and correct |
|
|
95
|
-
|
|
96
|
-
The `doc-generator` skill auto-triggers when Claude detects your docs are outdated.
|
|
97
|
-
|
|
98
|
-
## What it detects
|
|
99
|
-
|
|
100
|
-
**10+ languages** and **25+ frameworks** out of the box:
|
|
74
|
+
Claude AI reads your actual code, but the following are auto-detected for context:
|
|
101
75
|
|
|
102
76
|
- **Languages**: TypeScript, JavaScript, Python, Go, Rust, Ruby, PHP, Java, Kotlin, C#
|
|
103
77
|
- **Frameworks**: Next.js, Vite, Nuxt, SvelteKit, Astro, Angular, Django, FastAPI, Flask, Rails, Laravel, Spring Boot, and more
|
|
@@ -106,51 +80,39 @@ The `doc-generator` skill auto-triggers when Claude detects your docs are outdat
|
|
|
106
80
|
- **CI/CD**: GitHub Actions, GitLab CI, Jenkins, CircleCI
|
|
107
81
|
- **Linters/formatters**: ESLint, Biome, Prettier, Ruff, RuboCop, golangci-lint, Clippy
|
|
108
82
|
|
|
109
|
-
## CLI
|
|
83
|
+
## CLI Reference
|
|
110
84
|
|
|
111
85
|
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Commands:
|
|
121
|
-
init [dir] Interactive setup (default when no command given)
|
|
122
|
-
generate Non-interactive generation (templates only)
|
|
123
|
-
validate Check documentation completeness
|
|
86
|
+
claudenv Install /claudenv into ~/.claude/ (default)
|
|
87
|
+
claudenv install Same as above (explicit)
|
|
88
|
+
claudenv install -f Reinstall, overwriting existing files
|
|
89
|
+
claudenv uninstall Remove /claudenv from ~/.claude/
|
|
90
|
+
claudenv init [dir] Legacy: static analysis + terminal prompts (no AI)
|
|
91
|
+
claudenv init -y Legacy: skip prompts, auto-detect everything
|
|
92
|
+
claudenv generate Templates only, no scaffold
|
|
93
|
+
claudenv validate Check documentation completeness
|
|
124
94
|
```
|
|
125
95
|
|
|
126
|
-
##
|
|
96
|
+
## Alternative: Run Without Installing
|
|
127
97
|
|
|
128
98
|
```bash
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
npm link
|
|
133
|
-
|
|
134
|
-
# Then in any project:
|
|
135
|
-
claudenv
|
|
99
|
+
npx claudenv # npm
|
|
100
|
+
pnpm dlx claudenv # pnpm
|
|
101
|
+
bunx claudenv # bun
|
|
136
102
|
```
|
|
137
103
|
|
|
138
|
-
##
|
|
139
|
-
|
|
140
|
-
```javascript
|
|
141
|
-
import { detectTechStack, generateDocs, writeDocs, installScaffold } from 'claudenv';
|
|
104
|
+
## Uninstall
|
|
142
105
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
projectDescription: 'My awesome project',
|
|
147
|
-
generateRules: true,
|
|
148
|
-
generateHooks: true,
|
|
149
|
-
});
|
|
150
|
-
await writeDocs('/path/to/project', files);
|
|
151
|
-
await installScaffold('/path/to/project');
|
|
106
|
+
```bash
|
|
107
|
+
claudenv uninstall # Remove from ~/.claude/
|
|
108
|
+
npm uninstall -g claudenv
|
|
152
109
|
```
|
|
153
110
|
|
|
111
|
+
## Requirements
|
|
112
|
+
|
|
113
|
+
- Node.js >= 20
|
|
114
|
+
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI
|
|
115
|
+
|
|
154
116
|
## License
|
|
155
117
|
|
|
156
118
|
MIT
|
package/bin/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import { detectTechStack } from '../src/detector.js';
|
|
|
9
9
|
import { generateDocs, writeDocs, installScaffold } from '../src/generator.js';
|
|
10
10
|
import { validateClaudeMd, validateStructure, crossReferenceCheck } from '../src/validator.js';
|
|
11
11
|
import { runExistingProjectFlow, runColdStartFlow, buildDefaultConfig } from '../src/prompts.js';
|
|
12
|
+
import { installGlobal, uninstallGlobal } from '../src/installer.js';
|
|
12
13
|
|
|
13
14
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
15
|
const pkgJson = JSON.parse(await readFile(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
@@ -20,17 +21,28 @@ program
|
|
|
20
21
|
.description('One command to set up Claude Code documentation for any project')
|
|
21
22
|
.version(pkgJson.version);
|
|
22
23
|
|
|
23
|
-
// --- Default action:
|
|
24
|
+
// --- Default action: install global Claude Code command ---
|
|
24
25
|
program
|
|
25
|
-
.
|
|
26
|
-
.
|
|
27
|
-
.option('--overwrite', 'Overwrite existing files')
|
|
28
|
-
.action(runInit);
|
|
26
|
+
.option('-f, --force', 'Overwrite existing files')
|
|
27
|
+
.action(runInstall);
|
|
29
28
|
|
|
30
|
-
// ---
|
|
29
|
+
// --- install (explicit subcommand, same logic) ---
|
|
30
|
+
program
|
|
31
|
+
.command('install')
|
|
32
|
+
.description('Install /claudenv command globally into ~/.claude/')
|
|
33
|
+
.option('-f, --force', 'Overwrite existing files')
|
|
34
|
+
.action(runInstall);
|
|
35
|
+
|
|
36
|
+
// --- uninstall ---
|
|
37
|
+
program
|
|
38
|
+
.command('uninstall')
|
|
39
|
+
.description('Remove /claudenv command from ~/.claude/')
|
|
40
|
+
.action(runUninstall);
|
|
41
|
+
|
|
42
|
+
// --- init (legacy static flow for backward compatibility) ---
|
|
31
43
|
program
|
|
32
44
|
.command('init')
|
|
33
|
-
.description('
|
|
45
|
+
.description('Legacy: static analysis + interactive setup (no Claude AI)')
|
|
34
46
|
.argument('[dir]', 'Project directory', '.')
|
|
35
47
|
.option('-y, --yes', 'Skip prompts, use auto-detected defaults')
|
|
36
48
|
.option('--overwrite', 'Overwrite existing files')
|
|
@@ -102,7 +114,56 @@ program
|
|
|
102
114
|
});
|
|
103
115
|
|
|
104
116
|
// =============================================
|
|
105
|
-
//
|
|
117
|
+
// Install / Uninstall
|
|
118
|
+
// =============================================
|
|
119
|
+
async function runInstall(opts) {
|
|
120
|
+
console.log(`\n claudenv v${pkgJson.version}\n`);
|
|
121
|
+
console.log(' Installing Claude Code integration...\n');
|
|
122
|
+
|
|
123
|
+
const force = opts.force || false;
|
|
124
|
+
const { written, skipped } = await installGlobal({ force });
|
|
125
|
+
|
|
126
|
+
if (written.length > 0) {
|
|
127
|
+
console.log(` Installed ${written.length} file(s) to ~/.claude/:\n`);
|
|
128
|
+
for (const f of written) console.log(` + ${f}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (skipped.length > 0) {
|
|
132
|
+
console.log(`\n Skipped ${skipped.length} existing file(s) (use --force to overwrite):\n`);
|
|
133
|
+
for (const f of skipped) console.log(` ~ ${f}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (written.length === 0 && skipped.length > 0) {
|
|
137
|
+
console.log('\n Already installed. Use --force to reinstall.');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
console.log(`
|
|
141
|
+
Done! Now open Claude Code in any project and type:
|
|
142
|
+
|
|
143
|
+
/claudenv
|
|
144
|
+
|
|
145
|
+
Claude will analyze your project and generate documentation.
|
|
146
|
+
`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function runUninstall() {
|
|
150
|
+
console.log(`\n claudenv v${pkgJson.version}\n`);
|
|
151
|
+
console.log(' Removing Claude Code integration...\n');
|
|
152
|
+
|
|
153
|
+
const { removed } = await uninstallGlobal();
|
|
154
|
+
|
|
155
|
+
if (removed.length > 0) {
|
|
156
|
+
console.log(` Removed ${removed.length} item(s) from ~/.claude/:\n`);
|
|
157
|
+
for (const f of removed) console.log(` - ${f}`);
|
|
158
|
+
} else {
|
|
159
|
+
console.log(' Nothing to remove — not installed.');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
console.log();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// =============================================
|
|
166
|
+
// Legacy init logic
|
|
106
167
|
// =============================================
|
|
107
168
|
async function runInit(dirArg, opts) {
|
|
108
169
|
// Commander passes (dir, opts) for arguments, or (opts) for options-only
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudenv",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "One command to
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "One command to integrate Claude Code into any project — installs /claudenv command for AI-powered documentation generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"claudenv": "./bin/cli.js"
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
"prepublishOnly": "vitest run"
|
|
24
24
|
},
|
|
25
25
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
26
|
+
"node": ">=20"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@inquirer/prompts": "^
|
|
30
|
-
"commander": "^
|
|
31
|
-
"ejs": "^
|
|
32
|
-
"glob": "^
|
|
29
|
+
"@inquirer/prompts": "^8.0.0",
|
|
30
|
+
"commander": "^14.0.0",
|
|
31
|
+
"ejs": "^4.0.0",
|
|
32
|
+
"glob": "^13.0.0",
|
|
33
33
|
"smol-toml": "^1.3.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"vitest": "^
|
|
36
|
+
"vitest": "^4.0.0"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|
|
39
39
|
"claude",
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Set up Claude Code documentation for this project — analyze tech stack, generate CLAUDE.md, rules, hooks, commands, and skills
|
|
3
|
+
allowed-tools: Read, Write, Glob, Grep, Bash(find:*), Bash(cat:*), Bash(mkdir:*), Bash(cp:*), Bash(chmod:*)
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
argument-hint: [--force]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# claudenv — Project Documentation Setup
|
|
9
|
+
|
|
10
|
+
You are setting up Claude Code documentation for this project. Use your full capabilities to analyze the codebase — read files, understand architecture, and generate high-quality documentation.
|
|
11
|
+
|
|
12
|
+
## Phase 1: Deep Project Analysis
|
|
13
|
+
|
|
14
|
+
Scan the project thoroughly. Start with these discovery commands:
|
|
15
|
+
|
|
16
|
+
**Manifest files:**
|
|
17
|
+
!`find . -maxdepth 3 \( -name "package.json" -o -name "pyproject.toml" -o -name "go.mod" -o -name "Cargo.toml" -o -name "Gemfile" -o -name "composer.json" -o -name "pom.xml" -o -name "build.gradle*" -o -name "*.csproj" -o -name "requirements.txt" -o -name "setup.py" \) -not -path "*/node_modules/*" -not -path "*/.venv/*" -not -path "*/vendor/*" 2>/dev/null | head -20`
|
|
18
|
+
|
|
19
|
+
**Framework and tooling configs:**
|
|
20
|
+
!`find . -maxdepth 2 \( -name "tsconfig*.json" -o -name "next.config.*" -o -name "vite.config.*" -o -name "nuxt.config.*" -o -name "svelte.config.*" -o -name "astro.config.*" -o -name "angular.json" -o -name "manage.py" -o -name "docker-compose.*" -o -name "Dockerfile" -o -name ".eslintrc*" -o -name "biome.json" -o -name ".prettierrc*" -o -name "vitest.config.*" -o -name "jest.config.*" -o -name "pytest.ini" -o -name "conftest.py" -o -name "turbo.json" -o -name "nx.json" \) -not -path "*/node_modules/*" 2>/dev/null | head -30`
|
|
21
|
+
|
|
22
|
+
**CI/CD:**
|
|
23
|
+
!`find . -maxdepth 3 \( -path "*/.github/workflows/*" -o -name ".gitlab-ci.yml" -o -name "Jenkinsfile" -o -name ".circleci/config.yml" \) 2>/dev/null | head -10`
|
|
24
|
+
|
|
25
|
+
**Existing docs:**
|
|
26
|
+
!`find . -maxdepth 2 \( -name "README.md" -o -name "CLAUDE.md" -o -name "CONTRIBUTING.md" -o -name "_state.md" \) -not -path "*/node_modules/*" 2>/dev/null | head -10`
|
|
27
|
+
|
|
28
|
+
**Directory structure:**
|
|
29
|
+
!`ls -la`
|
|
30
|
+
|
|
31
|
+
Now **read the manifest files** you found (package.json, pyproject.toml, etc.) to understand:
|
|
32
|
+
- Project name and description
|
|
33
|
+
- Dependencies and their purposes
|
|
34
|
+
- Available scripts/commands
|
|
35
|
+
- Dev vs production dependencies
|
|
36
|
+
|
|
37
|
+
Also **read the README.md** if it exists — it often contains the best project description.
|
|
38
|
+
|
|
39
|
+
**Read 3-5 key source files** to understand the actual code architecture, patterns, and conventions used.
|
|
40
|
+
|
|
41
|
+
## Phase 2: Ask the User
|
|
42
|
+
|
|
43
|
+
Based on your analysis, ask the user these questions **one at a time**, providing your best guess as context:
|
|
44
|
+
|
|
45
|
+
1. **Project description**: "Based on my analysis, this appears to be [your analysis]. Is this correct, or would you describe it differently?"
|
|
46
|
+
2. **Deployment**: "Where is this deployed?" (Vercel, AWS, Docker, bare metal, etc.)
|
|
47
|
+
3. **Conventions**: "I noticed [patterns you found]. Are there other team conventions I should know about?"
|
|
48
|
+
4. **Focus areas**: "Are there areas of the codebase that need special attention?" (complex logic, frequent bugs, etc.)
|
|
49
|
+
|
|
50
|
+
If `$ARGUMENTS` includes `--force`, skip questions and use your best judgment from the analysis.
|
|
51
|
+
|
|
52
|
+
## Phase 3: Generate Documentation
|
|
53
|
+
|
|
54
|
+
Create the following files based on your REAL analysis of the code (not generic templates):
|
|
55
|
+
|
|
56
|
+
### 3.1 CLAUDE.md (project root)
|
|
57
|
+
Compact (under 60 lines) with these sections:
|
|
58
|
+
- `## Project overview` — one sentence with detected stack, based on what you actually found
|
|
59
|
+
- `## Commands` — all dev/build/test/lint/format commands from manifest files
|
|
60
|
+
- `## Architecture` — key directories with descriptions based on ACTUAL content you read
|
|
61
|
+
- `## Conventions` — @import references to rules files
|
|
62
|
+
- `## Workflow` — @import to workflow.md
|
|
63
|
+
- `## Memory` — reference to _state.md
|
|
64
|
+
- `## Rules` — project-specific rules including: "NEVER create documentation files (.md) unless the user explicitly requests it"
|
|
65
|
+
|
|
66
|
+
### 3.2 _state.md (project root)
|
|
67
|
+
Session memory file:
|
|
68
|
+
- `## Current Focus` — empty (user fills in)
|
|
69
|
+
- `## Key Decisions` — pre-fill with architectural decisions you detected
|
|
70
|
+
- `## Known Issues` — empty
|
|
71
|
+
- `## Session Notes` — empty
|
|
72
|
+
|
|
73
|
+
### 3.3 .claude/rules/code-style.md
|
|
74
|
+
YAML frontmatter with path globs. Include language-specific and framework-specific conventions based on what you actually found in the code.
|
|
75
|
+
|
|
76
|
+
### 3.4 .claude/rules/testing.md
|
|
77
|
+
YAML frontmatter with test path globs. Include detected test framework, commands, patterns.
|
|
78
|
+
|
|
79
|
+
### 3.5 .claude/rules/workflow.md
|
|
80
|
+
Claude Code workflow best practices:
|
|
81
|
+
- Plan mode usage
|
|
82
|
+
- /compact and /clear for context management
|
|
83
|
+
- Subagents for parallel tasks
|
|
84
|
+
- Memory via _state.md (read at start, update at end)
|
|
85
|
+
- Commit discipline
|
|
86
|
+
- NEVER create .md files unless explicitly asked
|
|
87
|
+
|
|
88
|
+
### 3.6 .claude/settings.json
|
|
89
|
+
Validation hooks configuration (PostToolUse hooks for Write operations on doc files).
|
|
90
|
+
|
|
91
|
+
**Present each file to the user for review before writing.** If `$ARGUMENTS` includes `--force`, write without confirmation.
|
|
92
|
+
|
|
93
|
+
## Phase 4: Install Project Commands & Skills
|
|
94
|
+
|
|
95
|
+
Copy the following scaffold files from the global skill directory into this project:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Create directories
|
|
99
|
+
mkdir -p .claude/commands .claude/skills/doc-generator/scripts .claude/skills/doc-generator/templates .claude/agents
|
|
100
|
+
|
|
101
|
+
# Copy project-level scaffold from global skill
|
|
102
|
+
cp ~/.claude/skills/claudenv/scaffold/.claude/commands/init-docs.md .claude/commands/init-docs.md
|
|
103
|
+
cp ~/.claude/skills/claudenv/scaffold/.claude/commands/update-docs.md .claude/commands/update-docs.md
|
|
104
|
+
cp ~/.claude/skills/claudenv/scaffold/.claude/commands/validate-docs.md .claude/commands/validate-docs.md
|
|
105
|
+
cp ~/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/SKILL.md .claude/skills/doc-generator/SKILL.md
|
|
106
|
+
cp ~/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/scripts/validate.sh .claude/skills/doc-generator/scripts/validate.sh
|
|
107
|
+
cp ~/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/templates/detection-patterns.md .claude/skills/doc-generator/templates/detection-patterns.md
|
|
108
|
+
cp ~/.claude/skills/claudenv/scaffold/.claude/agents/doc-analyzer.md .claude/agents/doc-analyzer.md
|
|
109
|
+
chmod +x .claude/skills/doc-generator/scripts/validate.sh
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
If any file already exists, **skip it** unless `$ARGUMENTS` includes `--force`.
|
|
113
|
+
|
|
114
|
+
## Phase 5: Validate
|
|
115
|
+
|
|
116
|
+
Run the validation script:
|
|
117
|
+
```bash
|
|
118
|
+
bash .claude/skills/doc-generator/scripts/validate.sh 2>&1 || true
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Fix any errors found.
|
|
122
|
+
|
|
123
|
+
## Phase 6: Summary
|
|
124
|
+
|
|
125
|
+
Print a summary of everything created:
|
|
126
|
+
```
|
|
127
|
+
claudenv setup complete!
|
|
128
|
+
|
|
129
|
+
Created:
|
|
130
|
+
+ CLAUDE.md
|
|
131
|
+
+ _state.md
|
|
132
|
+
+ .claude/rules/code-style.md
|
|
133
|
+
+ .claude/rules/testing.md
|
|
134
|
+
+ .claude/rules/workflow.md
|
|
135
|
+
+ .claude/settings.json
|
|
136
|
+
+ .claude/commands/init-docs.md
|
|
137
|
+
+ .claude/commands/update-docs.md
|
|
138
|
+
+ .claude/commands/validate-docs.md
|
|
139
|
+
+ .claude/skills/doc-generator/
|
|
140
|
+
+ .claude/agents/doc-analyzer.md
|
|
141
|
+
|
|
142
|
+
Available commands:
|
|
143
|
+
/init-docs — Regenerate documentation from scratch
|
|
144
|
+
/update-docs — Update docs when project changes
|
|
145
|
+
/validate-docs — Check documentation completeness
|
|
146
|
+
|
|
147
|
+
Next steps:
|
|
148
|
+
1. Review and edit CLAUDE.md
|
|
149
|
+
2. git add .claude/ CLAUDE.md _state.md && git commit -m "Add Claude Code docs"
|
|
150
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: claudenv
|
|
3
|
+
description: Detects missing or outdated project documentation and offers to generate or update it. Triggers when CLAUDE.md is missing, when the user mentions documentation setup, or when significant project changes are detected.
|
|
4
|
+
allowed-tools: Read, Write, Glob, Grep, Bash(find:*), Bash(cat:*), Bash(mkdir:*), Bash(cp:*), Bash(chmod:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# claudenv — Documentation Management Skill
|
|
8
|
+
|
|
9
|
+
## When to auto-trigger
|
|
10
|
+
- CLAUDE.md does not exist in the project root
|
|
11
|
+
- User mentions "documentation", "CLAUDE.md", "project setup", or "claudenv"
|
|
12
|
+
- User asks to configure Claude Code for their project
|
|
13
|
+
- After major refactoring that changes directory structure
|
|
14
|
+
|
|
15
|
+
## Capabilities
|
|
16
|
+
|
|
17
|
+
### Initial Setup
|
|
18
|
+
If no CLAUDE.md exists, suggest running `/claudenv` to set up full documentation.
|
|
19
|
+
|
|
20
|
+
### Update Detection
|
|
21
|
+
When working in a project with existing documentation, watch for:
|
|
22
|
+
- New dependencies added to manifest files
|
|
23
|
+
- New directories created that aren't in CLAUDE.md Architecture section
|
|
24
|
+
- Changed scripts in package.json / pyproject.toml
|
|
25
|
+
- New config files (linter, formatter, test framework)
|
|
26
|
+
|
|
27
|
+
When changes are detected, suggest running `/update-docs`.
|
|
28
|
+
|
|
29
|
+
### Validation
|
|
30
|
+
After documentation changes, run the validation script:
|
|
31
|
+
```bash
|
|
32
|
+
bash .claude/skills/doc-generator/scripts/validate.sh 2>&1 || true
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Reference
|
|
36
|
+
|
|
37
|
+
For tech stack detection patterns, see:
|
|
38
|
+
@~/.claude/skills/claudenv/templates/detection-patterns.md
|
|
39
|
+
|
|
40
|
+
## Project-level scaffold
|
|
41
|
+
|
|
42
|
+
The following files are available for installation into projects at `~/.claude/skills/claudenv/scaffold/`:
|
|
43
|
+
- `.claude/commands/init-docs.md` — Interactive documentation regeneration
|
|
44
|
+
- `.claude/commands/update-docs.md` — Refresh docs from current state
|
|
45
|
+
- `.claude/commands/validate-docs.md` — Run validation checks
|
|
46
|
+
- `.claude/skills/doc-generator/SKILL.md` — Per-project doc generation skill
|
|
47
|
+
- `.claude/skills/doc-generator/scripts/validate.sh` — Bash validation script
|
|
48
|
+
- `.claude/skills/doc-generator/templates/detection-patterns.md` — Detection reference
|
|
49
|
+
- `.claude/agents/doc-analyzer.md` — Read-only analysis subagent
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: doc-analyzer
|
|
3
|
+
description: Analyzes project structure for documentation. Use proactively when scanning codebases or evaluating documentation completeness.
|
|
4
|
+
tools: Read, Glob, Grep, Bash
|
|
5
|
+
model: sonnet
|
|
6
|
+
memory: project
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You are a documentation analysis specialist. Your job is to scan project files and determine the tech stack, build commands, testing patterns, and coding conventions.
|
|
10
|
+
|
|
11
|
+
## Analysis Process
|
|
12
|
+
|
|
13
|
+
When analyzing a project:
|
|
14
|
+
|
|
15
|
+
1. **Manifest files first** — Read package.json, pyproject.toml, go.mod, Cargo.toml, Gemfile, or composer.json to identify the language, dependencies, and scripts.
|
|
16
|
+
|
|
17
|
+
2. **Framework detection** — Look for framework config files (next.config.js, vite.config.ts, manage.py, etc.) to identify the application framework.
|
|
18
|
+
|
|
19
|
+
3. **Tooling inventory** — Scan for:
|
|
20
|
+
- Linter configs (.eslintrc*, biome.json, ruff.toml, .golangci.yml)
|
|
21
|
+
- Formatter configs (.prettierrc*, .editorconfig)
|
|
22
|
+
- Test configs (vitest.config.*, jest.config.*, pytest.ini, conftest.py)
|
|
23
|
+
- CI/CD files (.github/workflows/, .gitlab-ci.yml)
|
|
24
|
+
- Infrastructure (Dockerfile, docker-compose.yml, terraform/, *.tf)
|
|
25
|
+
|
|
26
|
+
4. **Read existing documentation** — Check for README.md, CONTRIBUTING.md, CLAUDE.md, and any docs/ directory.
|
|
27
|
+
|
|
28
|
+
5. **Directory structure** — Use Glob to map the top-level directory layout and identify key source directories.
|
|
29
|
+
|
|
30
|
+
## Output Format
|
|
31
|
+
|
|
32
|
+
Output your findings as structured JSON:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"language": "typescript",
|
|
37
|
+
"runtime": "node",
|
|
38
|
+
"framework": "next.js",
|
|
39
|
+
"packageManager": "pnpm",
|
|
40
|
+
"testFramework": "vitest",
|
|
41
|
+
"linter": "eslint",
|
|
42
|
+
"formatter": "prettier",
|
|
43
|
+
"ci": "github-actions",
|
|
44
|
+
"containerized": true,
|
|
45
|
+
"monorepo": null,
|
|
46
|
+
"scripts": {
|
|
47
|
+
"dev": "pnpm next dev",
|
|
48
|
+
"build": "pnpm next build",
|
|
49
|
+
"test": "pnpm vitest run",
|
|
50
|
+
"lint": "pnpm next lint"
|
|
51
|
+
},
|
|
52
|
+
"directories": [
|
|
53
|
+
{ "path": "src/app/", "description": "App Router pages and layouts" },
|
|
54
|
+
{ "path": "src/components/", "description": "React components" },
|
|
55
|
+
{ "path": "src/lib/", "description": "Shared utilities" }
|
|
56
|
+
],
|
|
57
|
+
"existingDocs": ["README.md"],
|
|
58
|
+
"recommendations": [
|
|
59
|
+
"CLAUDE.md is missing — generate one",
|
|
60
|
+
"No .claude/rules/ directory — consider adding code style rules"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Rules
|
|
66
|
+
|
|
67
|
+
- **NEVER modify files.** You are read-only.
|
|
68
|
+
- Only read and report findings.
|
|
69
|
+
- If you cannot determine something with confidence, say so rather than guessing.
|
|
70
|
+
- Prioritize accuracy over completeness.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze project and generate Claude Code documentation interactively
|
|
3
|
+
allowed-tools: Read, Write, Glob, Grep, Bash(find:*), Bash(cat:*), Bash(node:*)
|
|
4
|
+
argument-hint: [--force]
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Project Documentation Generator
|
|
9
|
+
|
|
10
|
+
You are generating Claude Code documentation for this project. Follow the phases below carefully.
|
|
11
|
+
|
|
12
|
+
## Phase 1: Project Analysis
|
|
13
|
+
|
|
14
|
+
Scan the project to detect the tech stack. Read the following detected files:
|
|
15
|
+
|
|
16
|
+
**Package managers and manifests:**
|
|
17
|
+
!`find . -maxdepth 3 \( -name "package.json" -o -name "pyproject.toml" -o -name "go.mod" -o -name "Cargo.toml" -o -name "Gemfile" -o -name "composer.json" -o -name "pom.xml" -o -name "build.gradle*" -o -name "*.csproj" \) -not -path "*/node_modules/*" 2>/dev/null | head -20`
|
|
18
|
+
|
|
19
|
+
**Framework configs:**
|
|
20
|
+
!`find . -maxdepth 2 \( -name "tsconfig.json" -o -name "next.config.*" -o -name "vite.config.*" -o -name "nuxt.config.*" -o -name "svelte.config.*" -o -name "astro.config.*" -o -name "angular.json" -o -name "manage.py" -o -name "docker-compose.*" \) -not -path "*/node_modules/*" 2>/dev/null | head -20`
|
|
21
|
+
|
|
22
|
+
**CI/CD:**
|
|
23
|
+
!`find . -maxdepth 3 \( -path "*/.github/workflows/*" -o -name ".gitlab-ci.yml" -o -name "Jenkinsfile" -o -name ".circleci/config.yml" \) 2>/dev/null | head -10`
|
|
24
|
+
|
|
25
|
+
**Existing documentation:**
|
|
26
|
+
!`find . -maxdepth 2 \( -name "README.md" -o -name "CLAUDE.md" -o -name "CONTRIBUTING.md" \) -not -path "*/node_modules/*" 2>/dev/null | head -10`
|
|
27
|
+
|
|
28
|
+
Read the manifest files you found above to understand dependencies, scripts, and project structure.
|
|
29
|
+
|
|
30
|
+
## Phase 2: Clarifying Questions
|
|
31
|
+
|
|
32
|
+
Based on your analysis, ask the user these questions **ONE AT A TIME**, waiting for each answer before proceeding to the next:
|
|
33
|
+
|
|
34
|
+
1. **Project description**: "What is the primary purpose of this project?" (e.g., SaaS web app, REST API, CLI tool, shared library)
|
|
35
|
+
2. **Deployment**: "What deployment target does this project use?" (e.g., Vercel, AWS, Docker, bare metal, not yet decided)
|
|
36
|
+
3. **Conventions**: "Are there any team conventions not captured in config files?" (naming patterns, branching strategy, PR process, coding standards)
|
|
37
|
+
4. **Focus areas**: "What areas of the codebase should Claude pay special attention to?" (critical business logic, complex algorithms, areas prone to bugs)
|
|
38
|
+
|
|
39
|
+
## Phase 3: Generate Documentation
|
|
40
|
+
|
|
41
|
+
After gathering all answers, generate these files:
|
|
42
|
+
|
|
43
|
+
### CLAUDE.md
|
|
44
|
+
Create a compact `CLAUDE.md` (under 60 lines) in the project root containing:
|
|
45
|
+
- **Project overview**: One-sentence description including detected stack
|
|
46
|
+
- **Commands**: All detected dev/build/test/lint commands with descriptions
|
|
47
|
+
- **Architecture**: Key directories and their purposes (read the actual directory structure)
|
|
48
|
+
- **Conventions**: @import references to `.claude/rules/code-style.md` and `.claude/rules/testing.md`
|
|
49
|
+
- **Workflow**: @import reference to `.claude/rules/workflow.md`
|
|
50
|
+
- **Memory**: Reference to `_state.md` for session persistence
|
|
51
|
+
- **Rules**: Project-specific rules, including: "NEVER create documentation files (.md) unless the user explicitly requests it"
|
|
52
|
+
|
|
53
|
+
### _state.md
|
|
54
|
+
Create `_state.md` in the project root for tracking project state across sessions:
|
|
55
|
+
- **Current Focus**: What is being worked on
|
|
56
|
+
- **Key Decisions**: Architecture and design decisions (pre-fill from detected stack)
|
|
57
|
+
- **Known Issues**: Bugs, tech debt, gotchas
|
|
58
|
+
- **Session Notes**: Context to preserve between sessions
|
|
59
|
+
|
|
60
|
+
### .claude/rules/code-style.md
|
|
61
|
+
Create coding convention rules based on detected linter, formatter, framework, and user-specified conventions. Include YAML frontmatter with path globs to scope the rules.
|
|
62
|
+
|
|
63
|
+
### .claude/rules/testing.md
|
|
64
|
+
Create testing rules based on detected test framework. Include test commands, file patterns, and best practices. Include YAML frontmatter with path globs.
|
|
65
|
+
|
|
66
|
+
### .claude/rules/workflow.md
|
|
67
|
+
Create Claude Code workflow best practices including: plan mode usage, /compact and /clear, subagents, memory via _state.md, commit discipline, and the rule to NEVER create .md files unless explicitly asked.
|
|
68
|
+
|
|
69
|
+
**Present each file to the user for confirmation before writing it.** If the argument `$ARGUMENTS` includes `--force`, write all files without confirmation.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Refresh project documentation from current state
|
|
3
|
+
allowed-tools: Read, Write, Glob, Grep, Bash(find:*), Bash(cat:*), Bash(diff:*)
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Update Project Documentation
|
|
8
|
+
|
|
9
|
+
You are updating the existing Claude Code documentation for this project.
|
|
10
|
+
|
|
11
|
+
## Step 1: Read Current Documentation
|
|
12
|
+
|
|
13
|
+
Read the existing documentation files:
|
|
14
|
+
- @CLAUDE.md
|
|
15
|
+
- Read any files referenced by @imports in CLAUDE.md
|
|
16
|
+
|
|
17
|
+
## Step 2: Scan Current State
|
|
18
|
+
|
|
19
|
+
Detect the current tech stack:
|
|
20
|
+
|
|
21
|
+
**Package managers:**
|
|
22
|
+
!`find . -maxdepth 3 \( -name "package.json" -o -name "pyproject.toml" -o -name "go.mod" -o -name "Cargo.toml" -o -name "Gemfile" \) -not -path "*/node_modules/*" 2>/dev/null | head -20`
|
|
23
|
+
|
|
24
|
+
**Framework configs:**
|
|
25
|
+
!`find . -maxdepth 2 \( -name "tsconfig.json" -o -name "next.config.*" -o -name "vite.config.*" -o -name "manage.py" -o -name "docker-compose.*" \) -not -path "*/node_modules/*" 2>/dev/null | head -20`
|
|
26
|
+
|
|
27
|
+
Read the manifest files to check for new dependencies, scripts, or configuration changes since the documentation was last generated.
|
|
28
|
+
|
|
29
|
+
## Step 3: Identify Changes
|
|
30
|
+
|
|
31
|
+
Compare the current state against the existing documentation:
|
|
32
|
+
- **New dependencies or tools** not mentioned in CLAUDE.md
|
|
33
|
+
- **Changed scripts** (renamed, added, or removed)
|
|
34
|
+
- **New directories** not covered in Architecture section
|
|
35
|
+
- **Stale references** to files or directories that no longer exist
|
|
36
|
+
- **Missing conventions** based on new config files (e.g., new linter added)
|
|
37
|
+
|
|
38
|
+
## Step 4: Propose Updates
|
|
39
|
+
|
|
40
|
+
Present a **diff-style summary** of proposed changes to each documentation file. For each change:
|
|
41
|
+
- Show what currently exists
|
|
42
|
+
- Show what should be updated
|
|
43
|
+
- Explain why the change is needed
|
|
44
|
+
|
|
45
|
+
Wait for user approval before writing any changes.
|
|
46
|
+
|
|
47
|
+
## Step 5: Apply Updates
|
|
48
|
+
|
|
49
|
+
After user approval, update the documentation files. Preserve any user-written content that was manually added — only update sections that correspond to detected/generated content.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Validate project documentation for completeness and correctness
|
|
3
|
+
allowed-tools: Read, Glob, Grep, Bash(bash:*)
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Validate Project Documentation
|
|
8
|
+
|
|
9
|
+
Run validation checks on the project's Claude Code documentation.
|
|
10
|
+
|
|
11
|
+
## Step 1: Run Bash Validation
|
|
12
|
+
|
|
13
|
+
Execute the validation script:
|
|
14
|
+
!`bash .claude/skills/doc-generator/scripts/validate.sh 2>&1 || true`
|
|
15
|
+
|
|
16
|
+
## Step 2: Deep Validation
|
|
17
|
+
|
|
18
|
+
Perform additional checks that require reading file contents:
|
|
19
|
+
|
|
20
|
+
1. **Read CLAUDE.md** and verify:
|
|
21
|
+
- All `@import` references resolve to existing files
|
|
22
|
+
- Commands in the ## Commands section match actual scripts in package.json / pyproject.toml / Makefile
|
|
23
|
+
- Directories in ## Architecture section actually exist
|
|
24
|
+
|
|
25
|
+
2. **Read .claude/rules/*.md** files and verify:
|
|
26
|
+
- YAML frontmatter `paths` globs match files that exist in the project
|
|
27
|
+
- Referenced tools (linters, formatters, test frameworks) are actually installed
|
|
28
|
+
|
|
29
|
+
3. **Read .claude/settings.json** and verify:
|
|
30
|
+
- Valid JSON structure
|
|
31
|
+
- Referenced hook scripts exist at the specified paths
|
|
32
|
+
|
|
33
|
+
## Step 3: Report
|
|
34
|
+
|
|
35
|
+
Present a clear summary:
|
|
36
|
+
- List all **errors** (things that must be fixed)
|
|
37
|
+
- List all **warnings** (things that should be reviewed)
|
|
38
|
+
- Provide a **pass/fail** verdict
|
|
39
|
+
|
|
40
|
+
If there are errors, suggest specific fixes for each one.
|
package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/SKILL.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: doc-generator
|
|
3
|
+
description: Generates and updates project documentation including CLAUDE.md, rules, and hooks. Use when the user asks about documentation, project setup, CLAUDE.md, or when detecting that documentation is missing or outdated.
|
|
4
|
+
allowed-tools: Read, Write, Glob, Grep, Bash(find:*), Bash(cat:*), Bash(node:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Documentation Generator Skill
|
|
8
|
+
|
|
9
|
+
## When to use
|
|
10
|
+
- User mentions documentation, CLAUDE.md, or project setup
|
|
11
|
+
- User asks to configure Claude Code for their project
|
|
12
|
+
- New files detected that change the tech stack (new framework, test runner, etc.)
|
|
13
|
+
- After major refactoring that changes directory structure
|
|
14
|
+
- When CLAUDE.md references files or directories that no longer exist
|
|
15
|
+
|
|
16
|
+
## Process
|
|
17
|
+
|
|
18
|
+
### 1. Detect Tech Stack
|
|
19
|
+
Scan the project root for manifest files, framework configs, and tooling:
|
|
20
|
+
|
|
21
|
+
@.claude/skills/doc-generator/templates/detection-patterns.md
|
|
22
|
+
|
|
23
|
+
### 2. Cross-Reference Existing Documentation
|
|
24
|
+
If CLAUDE.md already exists, read it and identify:
|
|
25
|
+
- Outdated commands or directory references
|
|
26
|
+
- Missing entries for new tools/dependencies
|
|
27
|
+
- Stale @imports pointing to removed files
|
|
28
|
+
|
|
29
|
+
### 3. Generate or Update
|
|
30
|
+
- For new documentation: generate CLAUDE.md, _state.md, .claude/rules/code-style.md, .claude/rules/testing.md, .claude/rules/workflow.md
|
|
31
|
+
- For updates: propose specific changes and wait for user approval
|
|
32
|
+
- Always present generated content for review before writing
|
|
33
|
+
- NEVER create .md files beyond the ones listed above unless the user explicitly asks
|
|
34
|
+
|
|
35
|
+
### 4. Validate
|
|
36
|
+
After writing, run the validation script:
|
|
37
|
+
```
|
|
38
|
+
bash .claude/skills/doc-generator/scripts/validate.sh
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Fix any errors before completing.
|
|
42
|
+
|
|
43
|
+
## Output Format
|
|
44
|
+
Generated CLAUDE.md should follow this structure:
|
|
45
|
+
- `# CLAUDE.md` heading
|
|
46
|
+
- `## Project overview` — one-sentence description with stack
|
|
47
|
+
- `## Commands` — all dev/build/test/lint commands
|
|
48
|
+
- `## Architecture` — key directories with descriptions
|
|
49
|
+
- `## Conventions` — @imports to code-style.md and testing.md
|
|
50
|
+
- `## Workflow` — @import to workflow.md (Claude Code best practices)
|
|
51
|
+
- `## Memory` — reference to _state.md for session persistence
|
|
52
|
+
- `## Rules` — project-specific rules as bullet points
|
|
53
|
+
|
|
54
|
+
Additionally generate:
|
|
55
|
+
- `_state.md` — project state tracking (decisions, focus, known issues)
|
|
56
|
+
- `.claude/rules/workflow.md` — Claude Code workflow best practices
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Documentation validation script for Claude Code hooks.
|
|
3
|
+
# Exit 0 = success, Exit 2 = block action (sends stderr to Claude).
|
|
4
|
+
# POSIX-compatible for macOS and Linux.
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
ERRORS=0
|
|
8
|
+
WARNINGS=0
|
|
9
|
+
|
|
10
|
+
error() {
|
|
11
|
+
echo "ERROR: $1" >&2
|
|
12
|
+
ERRORS=$((ERRORS + 1))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
warn() {
|
|
16
|
+
echo "WARN: $1" >&2
|
|
17
|
+
WARNINGS=$((WARNINGS + 1))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ok() {
|
|
21
|
+
echo "OK: $1"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# --- Required files ---
|
|
25
|
+
|
|
26
|
+
if [ -f "CLAUDE.md" ] && [ -s "CLAUDE.md" ]; then
|
|
27
|
+
ok "CLAUDE.md exists and is non-empty"
|
|
28
|
+
else
|
|
29
|
+
error "CLAUDE.md is missing or empty"
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# --- Required sections in CLAUDE.md ---
|
|
33
|
+
|
|
34
|
+
if [ -f "CLAUDE.md" ]; then
|
|
35
|
+
for section in "## Commands" "## Architecture"; do
|
|
36
|
+
if grep -q "^${section}" CLAUDE.md 2>/dev/null; then
|
|
37
|
+
ok "CLAUDE.md has ${section}"
|
|
38
|
+
else
|
|
39
|
+
error "CLAUDE.md is missing required section: ${section}"
|
|
40
|
+
fi
|
|
41
|
+
done
|
|
42
|
+
|
|
43
|
+
# Check that ## Commands has at least one backtick-quoted command
|
|
44
|
+
# Use awk instead of head -n -1 for macOS compatibility
|
|
45
|
+
COMMANDS_SECTION=$(sed -n '/^## Commands/,/^## /p' CLAUDE.md | awk 'NR>1{print prev} {prev=$0}')
|
|
46
|
+
if echo "$COMMANDS_SECTION" | grep -q '`'; then
|
|
47
|
+
ok "## Commands section contains command examples"
|
|
48
|
+
else
|
|
49
|
+
warn "## Commands section has no inline code examples"
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# Check @import references
|
|
53
|
+
while IFS= read -r line; do
|
|
54
|
+
# Skip lines inside code blocks
|
|
55
|
+
case "$line" in
|
|
56
|
+
'```'*) continue ;;
|
|
57
|
+
esac
|
|
58
|
+
# Match bare @path lines (not emails, not inline)
|
|
59
|
+
if echo "$line" | grep -qE '^@[^@[:space:]]+$'; then
|
|
60
|
+
IMPORT_PATH=$(echo "$line" | sed 's/^@//')
|
|
61
|
+
# Resolve ~ to HOME
|
|
62
|
+
case "$IMPORT_PATH" in
|
|
63
|
+
'~/'*) IMPORT_PATH="${HOME}/${IMPORT_PATH#\~/}" ;;
|
|
64
|
+
esac
|
|
65
|
+
if [ -f "$IMPORT_PATH" ]; then
|
|
66
|
+
ok "@import ${IMPORT_PATH} resolves"
|
|
67
|
+
else
|
|
68
|
+
error "@import reference '${IMPORT_PATH}' does not resolve to a file"
|
|
69
|
+
fi
|
|
70
|
+
fi
|
|
71
|
+
done < CLAUDE.md
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
# --- Optional structure checks ---
|
|
75
|
+
|
|
76
|
+
if [ -d ".claude" ]; then
|
|
77
|
+
ok ".claude/ directory exists"
|
|
78
|
+
else
|
|
79
|
+
warn ".claude/ directory not found"
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
if [ -f ".claude/settings.json" ]; then
|
|
83
|
+
# Validate JSON syntax (requires python or node)
|
|
84
|
+
if command -v node >/dev/null 2>&1; then
|
|
85
|
+
if node -e "JSON.parse(require('fs').readFileSync('.claude/settings.json','utf-8'))" 2>/dev/null; then
|
|
86
|
+
ok ".claude/settings.json is valid JSON"
|
|
87
|
+
else
|
|
88
|
+
error ".claude/settings.json is not valid JSON"
|
|
89
|
+
fi
|
|
90
|
+
elif command -v python3 >/dev/null 2>&1; then
|
|
91
|
+
if python3 -c "import json; json.load(open('.claude/settings.json'))" 2>/dev/null; then
|
|
92
|
+
ok ".claude/settings.json is valid JSON"
|
|
93
|
+
else
|
|
94
|
+
error ".claude/settings.json is not valid JSON"
|
|
95
|
+
fi
|
|
96
|
+
fi
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# --- Summary ---
|
|
100
|
+
|
|
101
|
+
echo ""
|
|
102
|
+
echo "Validation complete: ${ERRORS} error(s), ${WARNINGS} warning(s)"
|
|
103
|
+
|
|
104
|
+
if [ "$ERRORS" -gt 0 ]; then
|
|
105
|
+
exit 2
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
exit 0
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Tech Stack Detection Patterns
|
|
2
|
+
|
|
3
|
+
Use these patterns to identify the project's tech stack by scanning for files.
|
|
4
|
+
|
|
5
|
+
## Language / Runtime Detection (check manifest files first)
|
|
6
|
+
|
|
7
|
+
| File | Language | Runtime |
|
|
8
|
+
|------|----------|---------|
|
|
9
|
+
| `package.json` | JavaScript/TypeScript | Node.js |
|
|
10
|
+
| `pyproject.toml`, `setup.py`, `requirements.txt` | Python | Python |
|
|
11
|
+
| `go.mod` | Go | Go |
|
|
12
|
+
| `Cargo.toml` | Rust | Rust |
|
|
13
|
+
| `Gemfile` | Ruby | Ruby |
|
|
14
|
+
| `composer.json` | PHP | PHP |
|
|
15
|
+
| `pom.xml`, `build.gradle`, `build.gradle.kts` | Java/Kotlin | JVM |
|
|
16
|
+
| `*.csproj`, `*.sln` | C# | .NET |
|
|
17
|
+
|
|
18
|
+
**TypeScript override**: If `tsconfig.json` exists alongside `package.json`, the language is TypeScript.
|
|
19
|
+
|
|
20
|
+
## Framework Detection (check config files)
|
|
21
|
+
|
|
22
|
+
| File | Framework |
|
|
23
|
+
|------|-----------|
|
|
24
|
+
| `next.config.js/mjs/ts` | Next.js |
|
|
25
|
+
| `nuxt.config.ts/js` | Nuxt |
|
|
26
|
+
| `vite.config.js/ts/mts` | Vite |
|
|
27
|
+
| `svelte.config.js` | SvelteKit |
|
|
28
|
+
| `astro.config.mjs/ts` | Astro |
|
|
29
|
+
| `angular.json` | Angular |
|
|
30
|
+
| `manage.py` | Django |
|
|
31
|
+
| `config/routes.rb` | Rails |
|
|
32
|
+
| `artisan` | Laravel |
|
|
33
|
+
| `application.properties/yml` | Spring Boot |
|
|
34
|
+
|
|
35
|
+
## Package Manager Detection (check lockfiles)
|
|
36
|
+
|
|
37
|
+
| File | Package Manager |
|
|
38
|
+
|------|----------------|
|
|
39
|
+
| `package-lock.json` | npm |
|
|
40
|
+
| `yarn.lock` | Yarn |
|
|
41
|
+
| `pnpm-lock.yaml` | pnpm |
|
|
42
|
+
| `bun.lockb`, `bun.lock` | Bun |
|
|
43
|
+
| `poetry.lock` | Poetry |
|
|
44
|
+
| `Pipfile.lock` | Pipenv |
|
|
45
|
+
| `uv.lock` | uv |
|
|
46
|
+
|
|
47
|
+
## Test Framework Detection
|
|
48
|
+
|
|
49
|
+
| File | Framework |
|
|
50
|
+
|------|-----------|
|
|
51
|
+
| `vitest.config.*` | Vitest |
|
|
52
|
+
| `jest.config.*` | Jest |
|
|
53
|
+
| `playwright.config.*` | Playwright |
|
|
54
|
+
| `cypress.config.*` | Cypress |
|
|
55
|
+
| `pytest.ini`, `conftest.py` | pytest |
|
|
56
|
+
| `.rspec` | RSpec |
|
|
57
|
+
|
|
58
|
+
Also check dependencies in `package.json` or `pyproject.toml`.
|
|
59
|
+
|
|
60
|
+
## CI/CD Detection
|
|
61
|
+
|
|
62
|
+
| Path | System |
|
|
63
|
+
|------|--------|
|
|
64
|
+
| `.github/workflows/*.yml` | GitHub Actions |
|
|
65
|
+
| `.gitlab-ci.yml` | GitLab CI |
|
|
66
|
+
| `Jenkinsfile` | Jenkins |
|
|
67
|
+
| `.circleci/config.yml` | CircleCI |
|
|
68
|
+
|
|
69
|
+
## Monorepo Detection
|
|
70
|
+
|
|
71
|
+
| File | Tool |
|
|
72
|
+
|------|------|
|
|
73
|
+
| `turbo.json` | Turborepo |
|
|
74
|
+
| `nx.json` | Nx |
|
|
75
|
+
| `lerna.json` | Lerna |
|
|
76
|
+
| `pnpm-workspace.yaml` | pnpm workspaces |
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Tech Stack Detection Patterns
|
|
2
|
+
|
|
3
|
+
Use these patterns to identify the project's tech stack by scanning for files.
|
|
4
|
+
|
|
5
|
+
## Language / Runtime Detection (check manifest files first)
|
|
6
|
+
|
|
7
|
+
| File | Language | Runtime |
|
|
8
|
+
|------|----------|---------|
|
|
9
|
+
| `package.json` | JavaScript/TypeScript | Node.js |
|
|
10
|
+
| `pyproject.toml`, `setup.py`, `requirements.txt` | Python | Python |
|
|
11
|
+
| `go.mod` | Go | Go |
|
|
12
|
+
| `Cargo.toml` | Rust | Rust |
|
|
13
|
+
| `Gemfile` | Ruby | Ruby |
|
|
14
|
+
| `composer.json` | PHP | PHP |
|
|
15
|
+
| `pom.xml`, `build.gradle`, `build.gradle.kts` | Java/Kotlin | JVM |
|
|
16
|
+
| `*.csproj`, `*.sln` | C# | .NET |
|
|
17
|
+
|
|
18
|
+
**TypeScript override**: If `tsconfig.json` exists alongside `package.json`, the language is TypeScript.
|
|
19
|
+
|
|
20
|
+
## Framework Detection (check config files)
|
|
21
|
+
|
|
22
|
+
| File | Framework |
|
|
23
|
+
|------|-----------|
|
|
24
|
+
| `next.config.js/mjs/ts` | Next.js |
|
|
25
|
+
| `nuxt.config.ts/js` | Nuxt |
|
|
26
|
+
| `vite.config.js/ts/mts` | Vite |
|
|
27
|
+
| `svelte.config.js` | SvelteKit |
|
|
28
|
+
| `astro.config.mjs/ts` | Astro |
|
|
29
|
+
| `angular.json` | Angular |
|
|
30
|
+
| `manage.py` | Django |
|
|
31
|
+
| `config/routes.rb` | Rails |
|
|
32
|
+
| `artisan` | Laravel |
|
|
33
|
+
| `application.properties/yml` | Spring Boot |
|
|
34
|
+
|
|
35
|
+
## Package Manager Detection (check lockfiles)
|
|
36
|
+
|
|
37
|
+
| File | Package Manager |
|
|
38
|
+
|------|----------------|
|
|
39
|
+
| `package-lock.json` | npm |
|
|
40
|
+
| `yarn.lock` | Yarn |
|
|
41
|
+
| `pnpm-lock.yaml` | pnpm |
|
|
42
|
+
| `bun.lockb`, `bun.lock` | Bun |
|
|
43
|
+
| `poetry.lock` | Poetry |
|
|
44
|
+
| `Pipfile.lock` | Pipenv |
|
|
45
|
+
| `uv.lock` | uv |
|
|
46
|
+
|
|
47
|
+
## Test Framework Detection
|
|
48
|
+
|
|
49
|
+
| File | Framework |
|
|
50
|
+
|------|-----------|
|
|
51
|
+
| `vitest.config.*` | Vitest |
|
|
52
|
+
| `jest.config.*` | Jest |
|
|
53
|
+
| `playwright.config.*` | Playwright |
|
|
54
|
+
| `cypress.config.*` | Cypress |
|
|
55
|
+
| `pytest.ini`, `conftest.py` | pytest |
|
|
56
|
+
| `.rspec` | RSpec |
|
|
57
|
+
|
|
58
|
+
Also check dependencies in `package.json` or `pyproject.toml`.
|
|
59
|
+
|
|
60
|
+
## CI/CD Detection
|
|
61
|
+
|
|
62
|
+
| Path | System |
|
|
63
|
+
|------|--------|
|
|
64
|
+
| `.github/workflows/*.yml` | GitHub Actions |
|
|
65
|
+
| `.gitlab-ci.yml` | GitLab CI |
|
|
66
|
+
| `Jenkinsfile` | Jenkins |
|
|
67
|
+
| `.circleci/config.yml` | CircleCI |
|
|
68
|
+
|
|
69
|
+
## Monorepo Detection
|
|
70
|
+
|
|
71
|
+
| File | Tool |
|
|
72
|
+
|------|------|
|
|
73
|
+
| `turbo.json` | Turborepo |
|
|
74
|
+
| `nx.json` | Nx |
|
|
75
|
+
| `lerna.json` | Lerna |
|
|
76
|
+
| `pnpm-workspace.yaml` | pnpm workspaces |
|
package/src/installer.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { mkdir, cp, rm, readdir, stat } from 'node:fs/promises';
|
|
2
|
+
import { join, dirname, relative } from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const SCAFFOLD_GLOBAL = join(__dirname, '..', 'scaffold', 'global');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get the path to ~/.claude/
|
|
11
|
+
*/
|
|
12
|
+
function getClaudeHome() {
|
|
13
|
+
return join(homedir(), '.claude');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Recursively list all files in a directory (relative paths).
|
|
18
|
+
*/
|
|
19
|
+
async function listFiles(dir, base = dir) {
|
|
20
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
21
|
+
const files = [];
|
|
22
|
+
for (const entry of entries) {
|
|
23
|
+
const full = join(dir, entry.name);
|
|
24
|
+
if (entry.isDirectory()) {
|
|
25
|
+
files.push(...await listFiles(full, base));
|
|
26
|
+
} else {
|
|
27
|
+
files.push(relative(base, full));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return files;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Install global Claude Code artifacts to ~/.claude/.
|
|
35
|
+
* Copies scaffold/global/.claude/ contents into ~/.claude/.
|
|
36
|
+
*
|
|
37
|
+
* @param {object} [options]
|
|
38
|
+
* @param {boolean} [options.force] - Overwrite existing files
|
|
39
|
+
* @param {string} [options.claudeHome] - Override ~/.claude/ path (for testing)
|
|
40
|
+
* @returns {Promise<{written: string[], skipped: string[]}>}
|
|
41
|
+
*/
|
|
42
|
+
export async function installGlobal(options = {}) {
|
|
43
|
+
const { force = false, claudeHome } = options;
|
|
44
|
+
const targetBase = claudeHome || getClaudeHome();
|
|
45
|
+
const sourceBase = join(SCAFFOLD_GLOBAL, '.claude');
|
|
46
|
+
|
|
47
|
+
const files = await listFiles(sourceBase);
|
|
48
|
+
const written = [];
|
|
49
|
+
const skipped = [];
|
|
50
|
+
|
|
51
|
+
for (const relPath of files) {
|
|
52
|
+
const src = join(sourceBase, relPath);
|
|
53
|
+
const dest = join(targetBase, relPath);
|
|
54
|
+
|
|
55
|
+
// Check if file exists and skip unless force
|
|
56
|
+
if (!force) {
|
|
57
|
+
try {
|
|
58
|
+
await stat(dest);
|
|
59
|
+
skipped.push(relPath);
|
|
60
|
+
continue;
|
|
61
|
+
} catch {
|
|
62
|
+
// File doesn't exist — proceed
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
await mkdir(dirname(dest), { recursive: true });
|
|
67
|
+
await cp(src, dest);
|
|
68
|
+
|
|
69
|
+
// Make .sh files executable
|
|
70
|
+
if (relPath.endsWith('.sh')) {
|
|
71
|
+
const { chmod } = await import('node:fs/promises');
|
|
72
|
+
await chmod(dest, 0o755);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
written.push(relPath);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return { written, skipped };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Remove global Claude Code artifacts from ~/.claude/.
|
|
83
|
+
*
|
|
84
|
+
* @param {object} [options]
|
|
85
|
+
* @param {string} [options.claudeHome] - Override ~/.claude/ path (for testing)
|
|
86
|
+
* @returns {Promise<{removed: string[]}>}
|
|
87
|
+
*/
|
|
88
|
+
export async function uninstallGlobal(options = {}) {
|
|
89
|
+
const { claudeHome } = options;
|
|
90
|
+
const targetBase = claudeHome || getClaudeHome();
|
|
91
|
+
const removed = [];
|
|
92
|
+
|
|
93
|
+
const targets = [
|
|
94
|
+
join(targetBase, 'commands', 'claudenv.md'),
|
|
95
|
+
join(targetBase, 'skills', 'claudenv'),
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
for (const target of targets) {
|
|
99
|
+
try {
|
|
100
|
+
await stat(target);
|
|
101
|
+
await rm(target, { recursive: true });
|
|
102
|
+
removed.push(relative(targetBase, target));
|
|
103
|
+
} catch {
|
|
104
|
+
// Doesn't exist — skip
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return { removed };
|
|
109
|
+
}
|