claudenv 1.0.1 → 1.1.0

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.
Files changed (22) hide show
  1. package/README.md +66 -104
  2. package/bin/cli.js +69 -8
  3. package/package.json +8 -8
  4. package/scaffold/.claude/commands/setup-mcp.md +115 -0
  5. package/scaffold/.claude/commands/update-docs.md +1 -0
  6. package/scaffold/.claude/skills/doc-generator/SKILL.md +3 -0
  7. package/scaffold/.claude/skills/doc-generator/templates/mcp-servers.md +168 -0
  8. package/scaffold/global/.claude/commands/claudenv.md +193 -0
  9. package/scaffold/global/.claude/commands/setup-mcp.md +115 -0
  10. package/scaffold/global/.claude/skills/claudenv/SKILL.md +59 -0
  11. package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/agents/doc-analyzer.md +70 -0
  12. package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/commands/init-docs.md +69 -0
  13. package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/commands/setup-mcp.md +115 -0
  14. package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/commands/update-docs.md +50 -0
  15. package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/commands/validate-docs.md +40 -0
  16. package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/SKILL.md +59 -0
  17. package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/scripts/validate.sh +108 -0
  18. package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/templates/detection-patterns.md +76 -0
  19. package/scaffold/global/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/templates/mcp-servers.md +168 -0
  20. package/scaffold/global/.claude/skills/claudenv/templates/detection-patterns.md +76 -0
  21. package/scaffold/global/.claude/skills/claudenv/templates/mcp-servers.md +168 -0
  22. package/src/installer.js +109 -0
@@ -0,0 +1,193 @@
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:*), Bash(curl:*)
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/skills/doc-generator/templates/mcp-servers.md .claude/skills/doc-generator/templates/mcp-servers.md
109
+ cp ~/.claude/skills/claudenv/scaffold/.claude/commands/setup-mcp.md .claude/commands/setup-mcp.md
110
+ cp ~/.claude/skills/claudenv/scaffold/.claude/agents/doc-analyzer.md .claude/agents/doc-analyzer.md
111
+ chmod +x .claude/skills/doc-generator/scripts/validate.sh
112
+ ```
113
+
114
+ If any file already exists, **skip it** unless `$ARGUMENTS` includes `--force`.
115
+
116
+ ## Phase 5: MCP Server Configuration
117
+
118
+ Configure MCP servers for this project by searching the official MCP Registry.
119
+
120
+ Read the MCP server reference:
121
+ @~/.claude/skills/claudenv/templates/mcp-servers.md
122
+
123
+ **5.1 Identify technologies to search for:**
124
+ Based on your Phase 1 analysis, list the key technologies that might have MCP servers (databases, cloud services, APIs, dev tools).
125
+
126
+ **5.2 Search the registry:**
127
+ For each technology, query the MCP Registry API:
128
+ ```bash
129
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=<tech>&version=latest&limit=10'
130
+ ```
131
+
132
+ **5.3 Verify trust:**
133
+ For each candidate with an npm package, check monthly downloads:
134
+ ```bash
135
+ curl -s 'https://api.npmjs.org/downloads/point/last-month/<npm-package>'
136
+ ```
137
+ Filter out servers with <100 monthly downloads.
138
+
139
+ **5.4 Present recommendations:**
140
+ Group as Essential / Recommended / Optional. For each, explain why it's relevant and show download counts.
141
+
142
+ Ask the user which to configure. If `$ARGUMENTS` includes `--force`, auto-select Essential + Recommended.
143
+
144
+ **5.5 Generate `.mcp.json`:**
145
+ Write `.mcp.json` with selected servers using `${ENV_VAR}` placeholders for secrets. Follow the format in the MCP server reference.
146
+
147
+ **5.6 List environment variables:**
148
+ Tell the user how to configure required secrets:
149
+ ```
150
+ claude config set env.VAR_NAME "your-value"
151
+ ```
152
+
153
+ ## Phase 6: Validate
154
+
155
+ Run the validation script:
156
+ ```bash
157
+ bash .claude/skills/doc-generator/scripts/validate.sh 2>&1 || true
158
+ ```
159
+
160
+ Fix any errors found.
161
+
162
+ ## Phase 7: Summary
163
+
164
+ Print a summary of everything created:
165
+ ```
166
+ claudenv setup complete!
167
+
168
+ Created:
169
+ + CLAUDE.md
170
+ + _state.md
171
+ + .claude/rules/code-style.md
172
+ + .claude/rules/testing.md
173
+ + .claude/rules/workflow.md
174
+ + .claude/settings.json
175
+ + .claude/commands/init-docs.md
176
+ + .claude/commands/update-docs.md
177
+ + .claude/commands/validate-docs.md
178
+ + .claude/commands/setup-mcp.md
179
+ + .claude/skills/doc-generator/
180
+ + .claude/agents/doc-analyzer.md
181
+ + .mcp.json (if MCP servers were configured)
182
+
183
+ Available commands:
184
+ /init-docs — Regenerate documentation from scratch
185
+ /update-docs — Update docs when project changes
186
+ /validate-docs — Check documentation completeness
187
+ /setup-mcp — Add or update MCP server configuration
188
+
189
+ Next steps:
190
+ 1. Review and edit CLAUDE.md
191
+ 2. Configure any required MCP secrets: claude config set env.VAR_NAME "value"
192
+ 3. git add .claude/ CLAUDE.md _state.md .mcp.json && git commit -m "Add Claude Code docs"
193
+ ```
@@ -0,0 +1,115 @@
1
+ ---
2
+ description: Recommend and configure MCP servers based on project analysis
3
+ allowed-tools: Read, Write, Glob, Grep, Bash(curl:*), Bash(find:*), Bash(cat:*)
4
+ disable-model-invocation: true
5
+ argument-hint: [--force]
6
+ ---
7
+
8
+ # MCP Server Setup
9
+
10
+ You are configuring MCP servers for this project. Analyze the tech stack, search the official MCP Registry, verify trust signals, and generate `.mcp.json`.
11
+
12
+ ## Step 1: Analyze the Project
13
+
14
+ Understand what this project uses:
15
+
16
+ **Read existing documentation:**
17
+ - Read CLAUDE.md if it exists — it contains the tech stack summary
18
+ - Read _state.md if it exists
19
+
20
+ **Check for existing MCP config:**
21
+ - Read `.mcp.json` if it exists — you will merge new entries, not overwrite
22
+
23
+ **Scan manifest files:**
24
+ !`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 "requirements.txt" \) -not -path "*/node_modules/*" -not -path "*/.venv/*" -not -path "*/vendor/*" 2>/dev/null | head -20`
25
+
26
+ **Scan framework and tooling configs:**
27
+ !`find . -maxdepth 2 \( -name "tsconfig*.json" -o -name "next.config.*" -o -name "vite.config.*" -o -name "docker-compose.*" -o -name "Dockerfile" -o -name ".env*" -o -name "prisma" -o -name "drizzle.config.*" \) -not -path "*/node_modules/*" 2>/dev/null | head -20`
28
+
29
+ Read the manifest files you found. Identify:
30
+ - Programming languages and frameworks
31
+ - Databases (PostgreSQL, MongoDB, Redis, etc.)
32
+ - Cloud services (AWS, GCP, Azure)
33
+ - External APIs (Stripe, Sentry, etc.)
34
+ - Dev tools (Docker, GitHub Actions, etc.)
35
+
36
+ ## Step 2: Search the MCP Registry
37
+
38
+ Read the MCP server reference for search and evaluation guidance:
39
+ @~/.claude/skills/claudenv/templates/mcp-servers.md
40
+
41
+ For each major technology in the project, search the official MCP Registry API:
42
+ ```bash
43
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=<tech>&version=latest&limit=10'
44
+ ```
45
+
46
+ For each candidate server with an npm package, verify trust by checking monthly downloads:
47
+ ```bash
48
+ curl -s 'https://api.npmjs.org/downloads/point/last-month/<npm-package>'
49
+ ```
50
+
51
+ Optionally check GitHub stars for additional trust signal:
52
+ ```bash
53
+ curl -s 'https://api.github.com/repos/<owner>/<repo>'
54
+ ```
55
+
56
+ **Filtering rules:**
57
+ - Remove servers with <100 monthly npm downloads
58
+ - Rank by: npm downloads (primary) + GitHub stars (secondary) + description relevance
59
+ - When multiple servers exist for the same technology, pick the one with the highest downloads
60
+
61
+ ## Step 3: Present Recommendations
62
+
63
+ Group your recommendations into three tiers:
64
+
65
+ **Essential** — servers that directly support the project's core technologies (e.g., PostgreSQL server for a project using PostgreSQL)
66
+
67
+ **Recommended** — servers that enhance the development workflow (e.g., Context7 for library docs, GitHub for repo management)
68
+
69
+ **Optional** — servers that could be useful but aren't critical (e.g., Fetch for web content, Docker if Docker is used occasionally)
70
+
71
+ For each recommendation, explain:
72
+ - **What it does** and why it's relevant to THIS project
73
+ - **Monthly npm downloads** (trust signal)
74
+ - **Environment variables required** and whether they need secrets
75
+
76
+ Ask the user which servers to configure.
77
+
78
+ If `$ARGUMENTS` includes `--force`, auto-select all Essential and Recommended servers.
79
+
80
+ ## Step 4: Generate .mcp.json
81
+
82
+ Build the `.mcp.json` file with the selected servers following the format in the MCP server reference.
83
+
84
+ **If `.mcp.json` already exists:**
85
+ - Read it and parse the existing `mcpServers` entries
86
+ - Merge new servers into the existing config — do NOT remove or overwrite existing entries
87
+ - If a server key already exists, skip it (preserve the user's existing config)
88
+
89
+ **Key rules:**
90
+ - Use `${ENV_VAR}` placeholders for ALL secret environment variables — NEVER literal values
91
+ - Non-secret env vars can use literal values when appropriate
92
+ - Use `npx -y <package>@latest` for stdio/npm servers
93
+ - Use the `type` and `url` from remotes for HTTP/SSE servers
94
+
95
+ Write the `.mcp.json` file.
96
+
97
+ ## Step 5: Update CLAUDE.md
98
+
99
+ If CLAUDE.md exists, add or update an `## MCP Servers` section listing the configured servers and what they do. Keep it concise — one line per server.
100
+
101
+ If CLAUDE.md doesn't exist, skip this step and suggest running `/claudenv` first.
102
+
103
+ ## Step 6: Environment Variables
104
+
105
+ List all required environment variables and how to configure them:
106
+
107
+ ```
108
+ To configure secrets, run:
109
+ claude config set env.VAR_NAME "your-value"
110
+
111
+ Required environment variables:
112
+ VAR_NAME — Description of what this is and where to get it
113
+ ```
114
+
115
+ Remind the user that `.mcp.json` is safe to commit — it only contains placeholders, not actual secrets.
@@ -0,0 +1,59 @@
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
+ - `.mcp.json` does not exist in a project that has CLAUDE.md
12
+ - User mentions "documentation", "CLAUDE.md", "project setup", or "claudenv"
13
+ - User mentions "MCP", "MCP servers", or "mcp.json"
14
+ - User asks to configure Claude Code for their project
15
+ - After major refactoring that changes directory structure
16
+
17
+ ## Capabilities
18
+
19
+ ### Initial Setup
20
+ If no CLAUDE.md exists, suggest running `/claudenv` to set up full documentation.
21
+
22
+ ### Update Detection
23
+ When working in a project with existing documentation, watch for:
24
+ - New dependencies added to manifest files
25
+ - New directories created that aren't in CLAUDE.md Architecture section
26
+ - Changed scripts in package.json / pyproject.toml
27
+ - New config files (linter, formatter, test framework)
28
+
29
+ When changes are detected, suggest running `/update-docs`.
30
+
31
+ ### MCP Configuration
32
+ When `.mcp.json` is missing in a project that already has CLAUDE.md, suggest running `/setup-mcp` to configure MCP servers. When the user mentions MCP servers, offer to run `/setup-mcp`.
33
+
34
+ ### Validation
35
+ After documentation changes, run the validation script:
36
+ ```bash
37
+ bash .claude/skills/doc-generator/scripts/validate.sh 2>&1 || true
38
+ ```
39
+
40
+ ## Reference
41
+
42
+ For tech stack detection patterns, see:
43
+ @~/.claude/skills/claudenv/templates/detection-patterns.md
44
+
45
+ For MCP server search, evaluation, and configuration, see:
46
+ @~/.claude/skills/claudenv/templates/mcp-servers.md
47
+
48
+ ## Project-level scaffold
49
+
50
+ The following files are available for installation into projects at `~/.claude/skills/claudenv/scaffold/`:
51
+ - `.claude/commands/init-docs.md` — Interactive documentation regeneration
52
+ - `.claude/commands/update-docs.md` — Refresh docs from current state
53
+ - `.claude/commands/validate-docs.md` — Run validation checks
54
+ - `.claude/skills/doc-generator/SKILL.md` — Per-project doc generation skill
55
+ - `.claude/skills/doc-generator/scripts/validate.sh` — Bash validation script
56
+ - `.claude/skills/doc-generator/templates/detection-patterns.md` — Detection reference
57
+ - `.claude/commands/setup-mcp.md` — MCP server recommendation and setup
58
+ - `.claude/skills/doc-generator/templates/mcp-servers.md` — MCP registry reference
59
+ - `.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,115 @@
1
+ ---
2
+ description: Recommend and configure MCP servers based on project analysis
3
+ allowed-tools: Read, Write, Glob, Grep, Bash(curl:*), Bash(find:*), Bash(cat:*)
4
+ disable-model-invocation: true
5
+ argument-hint: [--force]
6
+ ---
7
+
8
+ # MCP Server Setup
9
+
10
+ You are configuring MCP servers for this project. Analyze the tech stack, search the official MCP Registry, verify trust signals, and generate `.mcp.json`.
11
+
12
+ ## Step 1: Analyze the Project
13
+
14
+ Understand what this project uses:
15
+
16
+ **Read existing documentation:**
17
+ - Read CLAUDE.md if it exists — it contains the tech stack summary
18
+ - Read _state.md if it exists
19
+
20
+ **Check for existing MCP config:**
21
+ - Read `.mcp.json` if it exists — you will merge new entries, not overwrite
22
+
23
+ **Scan manifest files:**
24
+ !`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 "requirements.txt" \) -not -path "*/node_modules/*" -not -path "*/.venv/*" -not -path "*/vendor/*" 2>/dev/null | head -20`
25
+
26
+ **Scan framework and tooling configs:**
27
+ !`find . -maxdepth 2 \( -name "tsconfig*.json" -o -name "next.config.*" -o -name "vite.config.*" -o -name "docker-compose.*" -o -name "Dockerfile" -o -name ".env*" -o -name "prisma" -o -name "drizzle.config.*" \) -not -path "*/node_modules/*" 2>/dev/null | head -20`
28
+
29
+ Read the manifest files you found. Identify:
30
+ - Programming languages and frameworks
31
+ - Databases (PostgreSQL, MongoDB, Redis, etc.)
32
+ - Cloud services (AWS, GCP, Azure)
33
+ - External APIs (Stripe, Sentry, etc.)
34
+ - Dev tools (Docker, GitHub Actions, etc.)
35
+
36
+ ## Step 2: Search the MCP Registry
37
+
38
+ Read the MCP server reference for search and evaluation guidance:
39
+ @.claude/skills/doc-generator/templates/mcp-servers.md
40
+
41
+ For each major technology in the project, search the official MCP Registry API:
42
+ ```bash
43
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=<tech>&version=latest&limit=10'
44
+ ```
45
+
46
+ For each candidate server with an npm package, verify trust by checking monthly downloads:
47
+ ```bash
48
+ curl -s 'https://api.npmjs.org/downloads/point/last-month/<npm-package>'
49
+ ```
50
+
51
+ Optionally check GitHub stars for additional trust signal:
52
+ ```bash
53
+ curl -s 'https://api.github.com/repos/<owner>/<repo>'
54
+ ```
55
+
56
+ **Filtering rules:**
57
+ - Remove servers with <100 monthly npm downloads
58
+ - Rank by: npm downloads (primary) + GitHub stars (secondary) + description relevance
59
+ - When multiple servers exist for the same technology, pick the one with the highest downloads
60
+
61
+ ## Step 3: Present Recommendations
62
+
63
+ Group your recommendations into three tiers:
64
+
65
+ **Essential** — servers that directly support the project's core technologies (e.g., PostgreSQL server for a project using PostgreSQL)
66
+
67
+ **Recommended** — servers that enhance the development workflow (e.g., Context7 for library docs, GitHub for repo management)
68
+
69
+ **Optional** — servers that could be useful but aren't critical (e.g., Fetch for web content, Docker if Docker is used occasionally)
70
+
71
+ For each recommendation, explain:
72
+ - **What it does** and why it's relevant to THIS project
73
+ - **Monthly npm downloads** (trust signal)
74
+ - **Environment variables required** and whether they need secrets
75
+
76
+ Ask the user which servers to configure.
77
+
78
+ If `$ARGUMENTS` includes `--force`, auto-select all Essential and Recommended servers.
79
+
80
+ ## Step 4: Generate .mcp.json
81
+
82
+ Build the `.mcp.json` file with the selected servers following the format in the MCP server reference.
83
+
84
+ **If `.mcp.json` already exists:**
85
+ - Read it and parse the existing `mcpServers` entries
86
+ - Merge new servers into the existing config — do NOT remove or overwrite existing entries
87
+ - If a server key already exists, skip it (preserve the user's existing config)
88
+
89
+ **Key rules:**
90
+ - Use `${ENV_VAR}` placeholders for ALL secret environment variables — NEVER literal values
91
+ - Non-secret env vars can use literal values when appropriate
92
+ - Use `npx -y <package>@latest` for stdio/npm servers
93
+ - Use the `type` and `url` from remotes for HTTP/SSE servers
94
+
95
+ Write the `.mcp.json` file.
96
+
97
+ ## Step 5: Update CLAUDE.md
98
+
99
+ If CLAUDE.md exists, add or update an `## MCP Servers` section listing the configured servers and what they do. Keep it concise — one line per server.
100
+
101
+ If CLAUDE.md doesn't exist, skip this step and suggest running `/claudenv` first.
102
+
103
+ ## Step 6: Environment Variables
104
+
105
+ List all required environment variables and how to configure them:
106
+
107
+ ```
108
+ To configure secrets, run:
109
+ claude config set env.VAR_NAME "your-value"
110
+
111
+ Required environment variables:
112
+ VAR_NAME — Description of what this is and where to get it
113
+ ```
114
+
115
+ Remind the user that `.mcp.json` is safe to commit — it only contains placeholders, not actual secrets.
@@ -0,0 +1,50 @@
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
+ - **Missing or outdated `.mcp.json`** — if `.mcp.json` doesn't exist, or if new technologies have been added that could benefit from MCP servers, suggest running `/setup-mcp`
38
+
39
+ ## Step 4: Propose Updates
40
+
41
+ Present a **diff-style summary** of proposed changes to each documentation file. For each change:
42
+ - Show what currently exists
43
+ - Show what should be updated
44
+ - Explain why the change is needed
45
+
46
+ Wait for user approval before writing any changes.
47
+
48
+ ## Step 5: Apply Updates
49
+
50
+ 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.