claudenv 1.0.1
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/LICENSE +21 -0
- package/README.md +156 -0
- package/bin/cli.js +205 -0
- package/package.json +60 -0
- package/scaffold/.claude/agents/doc-analyzer.md +70 -0
- package/scaffold/.claude/commands/init-docs.md +69 -0
- package/scaffold/.claude/commands/update-docs.md +49 -0
- package/scaffold/.claude/commands/validate-docs.md +40 -0
- package/scaffold/.claude/skills/doc-generator/SKILL.md +56 -0
- package/scaffold/.claude/skills/doc-generator/scripts/validate.sh +108 -0
- package/scaffold/.claude/skills/doc-generator/templates/detection-patterns.md +76 -0
- package/src/constants.js +237 -0
- package/src/detector.js +346 -0
- package/src/generator.js +259 -0
- package/src/index.js +5 -0
- package/src/prompts.js +267 -0
- package/src/validator.js +206 -0
- package/templates/claude-md.ejs +49 -0
- package/templates/rules-code-style.ejs +64 -0
- package/templates/rules-testing.ejs +64 -0
- package/templates/rules-workflow.ejs +49 -0
- package/templates/settings-json.ejs +28 -0
- package/templates/state-md.ejs +23 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AGoldian
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# claudenv
|
|
2
|
+
|
|
3
|
+
One command to set up [Claude Code](https://docs.anthropic.com/en/docs/claude-code) documentation for any project.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Run directly without installing — pick your package manager:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx claudenv # npm
|
|
11
|
+
pnpm dlx claudenv # pnpm
|
|
12
|
+
bunx claudenv # bun
|
|
13
|
+
yarn dlx claudenv # yarn
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or install globally:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm i -g claudenv
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cd your-project
|
|
26
|
+
npx claudenv
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Scans your project, detects the tech stack, asks a few questions, and generates everything Claude Code needs to understand your codebase.
|
|
30
|
+
|
|
31
|
+
Skip the questions with `-y`:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx claudenv -y
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage in Claude Code
|
|
38
|
+
|
|
39
|
+
### Option A: Global install + shell command
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm i -g claudenv
|
|
43
|
+
# Then inside Claude Code, just run:
|
|
44
|
+
claudenv
|
|
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.
|
|
50
|
+
|
|
51
|
+
## What gets generated
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
your-project/
|
|
55
|
+
├── CLAUDE.md # Project overview, commands, architecture
|
|
56
|
+
├── _state.md # Track decisions and context across sessions
|
|
57
|
+
├── .claude/
|
|
58
|
+
│ ├── rules/
|
|
59
|
+
│ │ ├── code-style.md # Coding conventions (scoped by file paths)
|
|
60
|
+
│ │ ├── testing.md # Testing patterns and commands
|
|
61
|
+
│ │ └── workflow.md # Claude Code best practices
|
|
62
|
+
│ ├── settings.json # Validation hooks
|
|
63
|
+
│ ├── commands/
|
|
64
|
+
│ │ ├── init-docs.md # /init-docs — regenerate docs interactively
|
|
65
|
+
│ │ ├── update-docs.md # /update-docs — refresh from current state
|
|
66
|
+
│ │ └── validate-docs.md # /validate-docs — check docs are correct
|
|
67
|
+
│ ├── skills/
|
|
68
|
+
│ │ └── doc-generator/ # Auto-invoked when docs need updating
|
|
69
|
+
│ │ ├── SKILL.md
|
|
70
|
+
│ │ ├── scripts/validate.sh
|
|
71
|
+
│ │ └── templates/detection-patterns.md
|
|
72
|
+
│ └── agents/
|
|
73
|
+
│ └── doc-analyzer.md # Read-only analysis subagent
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Key files
|
|
77
|
+
|
|
78
|
+
| File | Purpose |
|
|
79
|
+
|------|---------|
|
|
80
|
+
| `CLAUDE.md` | Compact project overview (< 60 lines) with `@import` references to rule files |
|
|
81
|
+
| `_state.md` | Tracks current focus, key decisions, known issues — persists context between sessions |
|
|
82
|
+
| `.claude/rules/workflow.md` | Best practices: plan mode, `/compact`, `/clear`, subagents, git discipline |
|
|
83
|
+
| `.claude/rules/code-style.md` | Language and framework-specific coding conventions |
|
|
84
|
+
| `.claude/rules/testing.md` | Test framework patterns and commands |
|
|
85
|
+
|
|
86
|
+
## After setup
|
|
87
|
+
|
|
88
|
+
Inside Claude Code, you get three slash commands:
|
|
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:
|
|
101
|
+
|
|
102
|
+
- **Languages**: TypeScript, JavaScript, Python, Go, Rust, Ruby, PHP, Java, Kotlin, C#
|
|
103
|
+
- **Frameworks**: Next.js, Vite, Nuxt, SvelteKit, Astro, Angular, Django, FastAPI, Flask, Rails, Laravel, Spring Boot, and more
|
|
104
|
+
- **Package managers**: npm, yarn, pnpm, bun, poetry, pipenv, uv, cargo, go modules
|
|
105
|
+
- **Test frameworks**: Vitest, Jest, Playwright, Cypress, pytest, RSpec, go test, cargo test
|
|
106
|
+
- **CI/CD**: GitHub Actions, GitLab CI, Jenkins, CircleCI
|
|
107
|
+
- **Linters/formatters**: ESLint, Biome, Prettier, Ruff, RuboCop, golangci-lint, Clippy
|
|
108
|
+
|
|
109
|
+
## CLI reference
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
Usage: claudenv [dir] [options]
|
|
113
|
+
|
|
114
|
+
Options:
|
|
115
|
+
-y, --yes Skip prompts, use auto-detected defaults
|
|
116
|
+
--overwrite Overwrite existing files
|
|
117
|
+
-V, --version Show version
|
|
118
|
+
-h, --help Show help
|
|
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
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Install from source
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
git clone https://github.com/AGoldian/claudenv.git
|
|
130
|
+
cd claudenv
|
|
131
|
+
npm install
|
|
132
|
+
npm link
|
|
133
|
+
|
|
134
|
+
# Then in any project:
|
|
135
|
+
claudenv
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Programmatic API
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
import { detectTechStack, generateDocs, writeDocs, installScaffold } from 'claudenv';
|
|
142
|
+
|
|
143
|
+
const detected = await detectTechStack('/path/to/project');
|
|
144
|
+
const { files } = await generateDocs('/path/to/project', {
|
|
145
|
+
...detected,
|
|
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');
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
MIT
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { resolve, join } from 'node:path';
|
|
5
|
+
import { readFile } from 'node:fs/promises';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { dirname } from 'node:path';
|
|
8
|
+
import { detectTechStack } from '../src/detector.js';
|
|
9
|
+
import { generateDocs, writeDocs, installScaffold } from '../src/generator.js';
|
|
10
|
+
import { validateClaudeMd, validateStructure, crossReferenceCheck } from '../src/validator.js';
|
|
11
|
+
import { runExistingProjectFlow, runColdStartFlow, buildDefaultConfig } from '../src/prompts.js';
|
|
12
|
+
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const pkgJson = JSON.parse(await readFile(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
15
|
+
|
|
16
|
+
const program = new Command();
|
|
17
|
+
|
|
18
|
+
program
|
|
19
|
+
.name('claudenv')
|
|
20
|
+
.description('One command to set up Claude Code documentation for any project')
|
|
21
|
+
.version(pkgJson.version);
|
|
22
|
+
|
|
23
|
+
// --- Default action: running without subcommand triggers init ---
|
|
24
|
+
program
|
|
25
|
+
.argument('[dir]', 'Project directory', '.')
|
|
26
|
+
.option('-y, --yes', 'Skip prompts, use auto-detected defaults')
|
|
27
|
+
.option('--overwrite', 'Overwrite existing files')
|
|
28
|
+
.action(runInit);
|
|
29
|
+
|
|
30
|
+
// --- init (explicit subcommand, same logic) ---
|
|
31
|
+
program
|
|
32
|
+
.command('init')
|
|
33
|
+
.description('Interactive setup — detect stack, ask questions, generate docs')
|
|
34
|
+
.argument('[dir]', 'Project directory', '.')
|
|
35
|
+
.option('-y, --yes', 'Skip prompts, use auto-detected defaults')
|
|
36
|
+
.option('--overwrite', 'Overwrite existing files')
|
|
37
|
+
.action(runInit);
|
|
38
|
+
|
|
39
|
+
// --- generate (templates only, no scaffold, no prompts) ---
|
|
40
|
+
program
|
|
41
|
+
.command('generate')
|
|
42
|
+
.description('Non-interactive generation (templates only, no Claude Code commands)')
|
|
43
|
+
.option('-d, --dir <path>', 'Project directory', '.')
|
|
44
|
+
.option('--overwrite', 'Overwrite existing files', false)
|
|
45
|
+
.option('--no-rules', 'Skip generating rules files')
|
|
46
|
+
.option('--no-hooks', 'Skip generating hooks/settings.json')
|
|
47
|
+
.action(async (opts) => {
|
|
48
|
+
const projectDir = resolve(opts.dir);
|
|
49
|
+
const detected = await detectTechStack(projectDir);
|
|
50
|
+
|
|
51
|
+
if (!detected.language) {
|
|
52
|
+
console.error('No project files detected. Use `init` for interactive setup.');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log(`Detected: ${detected.language}${detected.framework ? ` + ${detected.framework}` : ''}`);
|
|
57
|
+
|
|
58
|
+
const config = {
|
|
59
|
+
...detected,
|
|
60
|
+
projectDescription: `${detected.framework || detected.language} project`,
|
|
61
|
+
generateRules: opts.rules !== false,
|
|
62
|
+
generateHooks: opts.hooks !== false,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const { files } = await generateDocs(projectDir, config);
|
|
66
|
+
const { written, skipped } = await writeDocs(projectDir, files, {
|
|
67
|
+
overwrite: opts.overwrite,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
printFileResults(written, skipped);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// --- validate ---
|
|
74
|
+
program
|
|
75
|
+
.command('validate')
|
|
76
|
+
.description('Run validation checks on documentation')
|
|
77
|
+
.option('-d, --dir <path>', 'Project directory', '.')
|
|
78
|
+
.action(async (opts) => {
|
|
79
|
+
const projectDir = resolve(opts.dir);
|
|
80
|
+
let hasErrors = false;
|
|
81
|
+
|
|
82
|
+
console.log('Validating documentation...\n');
|
|
83
|
+
|
|
84
|
+
const claudeResult = await validateClaudeMd(join(projectDir, 'CLAUDE.md'));
|
|
85
|
+
printValidation('CLAUDE.md', claudeResult);
|
|
86
|
+
if (!claudeResult.valid) hasErrors = true;
|
|
87
|
+
|
|
88
|
+
const structResult = await validateStructure(projectDir);
|
|
89
|
+
printValidation('Structure', structResult);
|
|
90
|
+
if (!structResult.valid) hasErrors = true;
|
|
91
|
+
|
|
92
|
+
const xrefResult = await crossReferenceCheck(projectDir);
|
|
93
|
+
printValidation('Cross-references', xrefResult);
|
|
94
|
+
if (!xrefResult.valid) hasErrors = true;
|
|
95
|
+
|
|
96
|
+
if (hasErrors) {
|
|
97
|
+
console.log('\nValidation failed.');
|
|
98
|
+
process.exit(2);
|
|
99
|
+
} else {
|
|
100
|
+
console.log('\nAll checks passed.');
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// =============================================
|
|
105
|
+
// Main init logic
|
|
106
|
+
// =============================================
|
|
107
|
+
async function runInit(dirArg, opts) {
|
|
108
|
+
// Commander passes (dir, opts) for arguments, or (opts) for options-only
|
|
109
|
+
if (typeof dirArg === 'object') {
|
|
110
|
+
opts = dirArg;
|
|
111
|
+
dirArg = '.';
|
|
112
|
+
}
|
|
113
|
+
const projectDir = resolve(dirArg || '.');
|
|
114
|
+
const yes = opts.yes || false;
|
|
115
|
+
const overwrite = opts.overwrite || false;
|
|
116
|
+
|
|
117
|
+
console.log(`\n claudenv v${pkgJson.version}\n`);
|
|
118
|
+
console.log(` Scanning ${projectDir}...\n`);
|
|
119
|
+
|
|
120
|
+
// 1. Detect tech stack
|
|
121
|
+
const detected = await detectTechStack(projectDir);
|
|
122
|
+
const hasProject = detected.language !== null;
|
|
123
|
+
|
|
124
|
+
if (hasProject) {
|
|
125
|
+
const parts = [detected.language];
|
|
126
|
+
if (detected.framework) parts.push(detected.framework);
|
|
127
|
+
const extras = [
|
|
128
|
+
detected.packageManager,
|
|
129
|
+
detected.testFramework,
|
|
130
|
+
detected.linter,
|
|
131
|
+
detected.formatter,
|
|
132
|
+
].filter(Boolean);
|
|
133
|
+
console.log(` Detected: ${parts.join(' + ')}${extras.length ? ` (${extras.join(', ')})` : ''}\n`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// 2. Build config
|
|
137
|
+
let config;
|
|
138
|
+
if (yes) {
|
|
139
|
+
config = hasProject
|
|
140
|
+
? await buildDefaultConfig(detected, projectDir)
|
|
141
|
+
: {
|
|
142
|
+
language: null,
|
|
143
|
+
generateRules: true,
|
|
144
|
+
generateHooks: true,
|
|
145
|
+
projectDescription: 'New project',
|
|
146
|
+
};
|
|
147
|
+
} else {
|
|
148
|
+
config = hasProject
|
|
149
|
+
? await runExistingProjectFlow(detected)
|
|
150
|
+
: await runColdStartFlow();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// 3. Generate template-based files (CLAUDE.md, rules, settings.json)
|
|
154
|
+
const { files } = await generateDocs(projectDir, config);
|
|
155
|
+
const docResult = await writeDocs(projectDir, files, { overwrite });
|
|
156
|
+
|
|
157
|
+
// 4. Install scaffold (Claude Code commands, skills, agents)
|
|
158
|
+
const scaffoldResult = await installScaffold(projectDir, { overwrite });
|
|
159
|
+
|
|
160
|
+
// 5. Print results
|
|
161
|
+
const allWritten = [...docResult.written, ...scaffoldResult.written];
|
|
162
|
+
const allSkipped = [...docResult.skipped, ...scaffoldResult.skipped];
|
|
163
|
+
|
|
164
|
+
if (allWritten.length > 0) {
|
|
165
|
+
console.log(`\n Created ${allWritten.length} file(s):\n`);
|
|
166
|
+
for (const f of allWritten) console.log(` + ${f}`);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (allSkipped.length > 0) {
|
|
170
|
+
console.log(`\n Skipped ${allSkipped.length} existing file(s) (use --overwrite to replace):\n`);
|
|
171
|
+
for (const f of allSkipped) console.log(` ~ ${f}`);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 6. Next steps
|
|
175
|
+
console.log(`
|
|
176
|
+
Next steps:
|
|
177
|
+
1. Review and edit CLAUDE.md
|
|
178
|
+
2. In Claude Code, try: /init-docs /update-docs /validate-docs
|
|
179
|
+
3. git add .claude/ CLAUDE.md && git commit -m "Add Claude Code docs"
|
|
180
|
+
`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function printFileResults(written, skipped) {
|
|
184
|
+
if (written.length > 0) {
|
|
185
|
+
console.log(`Written ${written.length} file(s):`);
|
|
186
|
+
for (const f of written) console.log(` + ${f}`);
|
|
187
|
+
}
|
|
188
|
+
if (skipped.length > 0) {
|
|
189
|
+
console.log(`Skipped ${skipped.length} existing file(s) (use --overwrite):`);
|
|
190
|
+
for (const f of skipped) console.log(` ~ ${f}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function printValidation(label, result) {
|
|
195
|
+
const status = result.valid ? 'PASS' : 'FAIL';
|
|
196
|
+
console.log(`[${status}] ${label}`);
|
|
197
|
+
for (const err of result.errors) {
|
|
198
|
+
console.log(` ERROR: ${err}`);
|
|
199
|
+
}
|
|
200
|
+
for (const warn of result.warnings) {
|
|
201
|
+
console.log(` WARN: ${warn}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claudenv",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "One command to set up Claude Code documentation for any project — detects tech stack, generates CLAUDE.md, rules, hooks, commands, and skills",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"claudenv": "./bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./src/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./src/index.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin",
|
|
15
|
+
"src",
|
|
16
|
+
"templates",
|
|
17
|
+
"scaffold",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:watch": "vitest",
|
|
23
|
+
"prepublishOnly": "vitest run"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=18"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@inquirer/prompts": "^7.0.0",
|
|
30
|
+
"commander": "^13.0.0",
|
|
31
|
+
"ejs": "^3.1.10",
|
|
32
|
+
"glob": "^11.0.0",
|
|
33
|
+
"smol-toml": "^1.3.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"vitest": "^3.0.0"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"claude",
|
|
40
|
+
"claude-code",
|
|
41
|
+
"anthropic",
|
|
42
|
+
"documentation",
|
|
43
|
+
"generator",
|
|
44
|
+
"scaffold",
|
|
45
|
+
"CLAUDE.md",
|
|
46
|
+
"ai",
|
|
47
|
+
"developer-tools",
|
|
48
|
+
"cli"
|
|
49
|
+
],
|
|
50
|
+
"author": "AGoldian",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/AGoldian/claudenv.git"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://github.com/AGoldian/claudenv#readme",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/AGoldian/claudenv/issues"
|
|
58
|
+
},
|
|
59
|
+
"license": "MIT"
|
|
60
|
+
}
|
|
@@ -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.
|