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
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) documentation for any project.
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
- ## Installation
6
-
7
- Run directly without installing — pick your package manager:
5
+ ## Quick Start
8
6
 
9
7
  ```bash
10
- npx claudenv # npm
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
- Or install globally:
11
+ Done. Open Claude Code in any project and type `/claudenv`.
17
12
 
18
- ```bash
19
- npm i -g claudenv
20
- ```
13
+ ## How It Works
21
14
 
22
- ## Quick start
15
+ **One-time setup** — install and activate:
23
16
 
24
17
  ```bash
25
- cd your-project
26
- npx claudenv
18
+ npm i -g claudenv && claudenv
27
19
  ```
28
20
 
29
- Scans your project, detects the tech stack, asks a few questions, and generates everything Claude Code needs to understand your codebase.
21
+ This installs the `/claudenv` command globally into `~/.claude/`, making it available in every project.
30
22
 
31
- Skip the questions with `-y`:
23
+ **In any project** open Claude Code and type `/claudenv`.
32
24
 
33
- ```bash
34
- npx claudenv -y
35
- ```
36
-
37
- ## Usage in Claude Code
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
- ### Option A: Global install + shell command
32
+ **Step 3.** You now have three commands available in Claude Code:
40
33
 
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.
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 gets generated
40
+ ## What Gets Generated
52
41
 
53
42
  ```
54
43
  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
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 files
62
+ ### Key Files
77
63
 
78
64
  | File | Purpose |
79
65
  |------|---------|
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 |
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
- ## After setup
72
+ ## Tech Stack Detection
87
73
 
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:
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 reference
83
+ ## CLI Reference
110
84
 
111
85
  ```
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
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
- ## Install from source
96
+ ## Alternative: Run Without Installing
127
97
 
128
98
  ```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
99
+ npx claudenv # npm
100
+ pnpm dlx claudenv # pnpm
101
+ bunx claudenv # bun
136
102
  ```
137
103
 
138
- ## Programmatic API
139
-
140
- ```javascript
141
- import { detectTechStack, generateDocs, writeDocs, installScaffold } from 'claudenv';
104
+ ## Uninstall
142
105
 
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');
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: running without subcommand triggers init ---
24
+ // --- Default action: install global Claude Code command ---
24
25
  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);
26
+ .option('-f, --force', 'Overwrite existing files')
27
+ .action(runInstall);
29
28
 
30
- // --- init (explicit subcommand, same logic) ---
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('Interactive setup detect stack, ask questions, generate docs')
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
- // Main init logic
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.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",
3
+ "version": "1.1.0",
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": ">=18"
26
+ "node": ">=20"
27
27
  },
28
28
  "dependencies": {
29
- "@inquirer/prompts": "^7.0.0",
30
- "commander": "^13.0.0",
31
- "ejs": "^3.1.10",
32
- "glob": "^11.0.0",
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": "^3.0.0"
36
+ "vitest": "^4.0.0"
37
37
  },
38
38
  "keywords": [
39
39
  "claude",
@@ -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.
@@ -34,6 +34,7 @@ Compare the current state against the existing documentation:
34
34
  - **New directories** not covered in Architecture section
35
35
  - **Stale references** to files or directories that no longer exist
36
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`
37
38
 
38
39
  ## Step 4: Propose Updates
39
40
 
@@ -12,6 +12,7 @@ allowed-tools: Read, Write, Glob, Grep, Bash(find:*), Bash(cat:*), Bash(node:*)
12
12
  - New files detected that change the tech stack (new framework, test runner, etc.)
13
13
  - After major refactoring that changes directory structure
14
14
  - When CLAUDE.md references files or directories that no longer exist
15
+ - When `.mcp.json` is missing and the project has significant external dependencies
15
16
 
16
17
  ## Process
17
18
 
@@ -28,6 +29,7 @@ If CLAUDE.md already exists, read it and identify:
28
29
 
29
30
  ### 3. Generate or Update
30
31
  - For new documentation: generate CLAUDE.md, _state.md, .claude/rules/code-style.md, .claude/rules/testing.md, .claude/rules/workflow.md
32
+ - For MCP configuration: suggest running `/setup-mcp` to search the MCP Registry and generate `.mcp.json`
31
33
  - For updates: propose specific changes and wait for user approval
32
34
  - Always present generated content for review before writing
33
35
  - NEVER create .md files beyond the ones listed above unless the user explicitly asks
@@ -54,3 +56,4 @@ Generated CLAUDE.md should follow this structure:
54
56
  Additionally generate:
55
57
  - `_state.md` — project state tracking (decisions, focus, known issues)
56
58
  - `.claude/rules/workflow.md` — Claude Code workflow best practices
59
+ - `.mcp.json` — MCP server configuration (via `/setup-mcp`)
@@ -0,0 +1,168 @@
1
+ # MCP Server Reference — Registry Search & Configuration
2
+
3
+ ## 1. How to Search the Registry
4
+
5
+ The official MCP Registry API provides a searchable catalog of MCP servers. No authentication required.
6
+
7
+ **Endpoint**: `GET https://registry.modelcontextprotocol.io/v0.1/servers`
8
+
9
+ **Parameters**:
10
+ - `search=<term>` — case-insensitive substring match on server names and descriptions
11
+ - `version=latest` — return only the latest version of each server
12
+ - `limit=<n>` — max results per page (default ~100)
13
+
14
+ **Search strategy**:
15
+ 1. Analyze the project's tech stack from manifest files, configs, and source code
16
+ 2. Extract key technology names (languages, frameworks, databases, cloud services, tools)
17
+ 3. Search each technology individually — specific terms yield better results
18
+
19
+ **Example searches**:
20
+ ```bash
21
+ # Database
22
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=postgres&version=latest&limit=10'
23
+
24
+ # Cloud provider
25
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=aws&version=latest&limit=10'
26
+
27
+ # Monitoring
28
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=sentry&version=latest&limit=10'
29
+
30
+ # Version control
31
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=github&version=latest&limit=10'
32
+ ```
33
+
34
+ ## 2. How to Evaluate and Trust Results
35
+
36
+ ### Primary trust signal: npm download counts
37
+
38
+ For each candidate server that has an npm package, check monthly downloads:
39
+ ```bash
40
+ curl -s 'https://api.npmjs.org/downloads/point/last-month/<npm-package-name>'
41
+ # Returns: { "downloads": N, "package": "...", ... }
42
+ ```
43
+
44
+ - **Filter out** servers with <100 monthly downloads — likely unmaintained or experimental
45
+ - **Prefer** servers with 10,000+ monthly downloads — well-established and community-trusted
46
+ - **Strong signal** at 100,000+ downloads — widely adopted
47
+
48
+ ### Secondary trust signal: GitHub stars
49
+
50
+ If the server has a repository URL, check GitHub stars:
51
+ ```bash
52
+ curl -s 'https://api.github.com/repos/<owner>/<repo>'
53
+ # Check the "stargazers_count" field
54
+ ```
55
+
56
+ - Prefer repos with 100+ stars
57
+ - Stars indicate community interest but downloads are a stronger usage signal
58
+
59
+ ### Additional evaluation criteria
60
+
61
+ - **Prefer `packages` (npm/stdio) over `remotes` (hosted)** — stdio runs locally with no external dependency
62
+ - **Prefer well-known namespaces**: `io.modelcontextprotocol/*`, `io.github.modelcontextprotocol/*` are official
63
+ - **Read descriptions carefully** — pick servers that match the project's actual use case
64
+ - **Skip** servers that appear to be forks, test entries, or clearly unmaintained
65
+ - **When multiple servers exist for the same tech**, pick the one with highest npm downloads
66
+ - **Check `environmentVariables`** — servers requiring many complex env vars may be harder to set up
67
+
68
+ ## 3. How to Build .mcp.json
69
+
70
+ The `.mcp.json` file configures MCP servers for a project. It lives in the project root.
71
+
72
+ **Root structure**:
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "server-name": { ... }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### stdio servers (npm packages)
82
+
83
+ For servers with a `packages` entry of `registryType: "npm"`:
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "server-name": {
88
+ "command": "npx",
89
+ "args": ["-y", "<package-identifier>@latest"],
90
+ "env": {
91
+ "VAR_NAME": "${VAR_NAME}"
92
+ }
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ - Add any `packageArguments` with `type: "positional"` to the `args` array after the package name
99
+ - Map `environmentVariables` to the `env` object
100
+ - Use `${ENV_VAR}` placeholders for all variables with `isSecret: true`
101
+ - Non-secret env vars can use literal values when the value is project-specific and non-sensitive
102
+
103
+ ### HTTP/SSE servers (remote)
104
+
105
+ For servers with a `remotes` entry:
106
+ ```json
107
+ {
108
+ "mcpServers": {
109
+ "server-name": {
110
+ "type": "streamable-http",
111
+ "url": "https://example.com/mcp"
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ Use the `type` and `url` from the remote entry directly. Add `headers` if authentication is needed:
118
+ ```json
119
+ {
120
+ "type": "streamable-http",
121
+ "url": "https://example.com/mcp",
122
+ "headers": {
123
+ "Authorization": "Bearer ${API_KEY}"
124
+ }
125
+ }
126
+ ```
127
+
128
+ ## 4. Well-Known Servers
129
+
130
+ These are hints to help find the best option when search results are noisy. Always verify via the registry API — these names and packages may change.
131
+
132
+ | Technology | Search term | Known namespace | Notes |
133
+ |---|---|---|---|
134
+ | Library docs | `context7` | `io.github.upstash/context7` | Up-to-date docs for any library; useful for most projects |
135
+ | GitHub | `github` | `io.github.modelcontextprotocol/github` | Repo management, PRs, issues |
136
+ | PostgreSQL | `postgres` | `io.github.modelcontextprotocol/postgres` | Database queries; prefer read-only config |
137
+ | Filesystem | `filesystem` | `io.github.modelcontextprotocol/filesystem` | Scoped file access |
138
+ | Fetch | `fetch` | `io.github.modelcontextprotocol/fetch` | Web content retrieval |
139
+ | Sentry | `sentry` | — | Error tracking integration |
140
+ | Stripe | `stripe` | — | Payment API |
141
+ | Docker | `docker` | — | Container management |
142
+ | AWS | `aws` | — | Cloud services |
143
+ | Redis | `redis` | — | Cache and data store |
144
+ | MongoDB | `mongodb` | — | Document database |
145
+ | Slack | `slack` | — | Team communication |
146
+ | Linear | `linear` | — | Issue tracking |
147
+
148
+ ## 5. Security Rules
149
+
150
+ ### Secrets management
151
+ - **NEVER** put actual secret values in `.mcp.json` — use `${ENV_VAR}` placeholders
152
+ - Secret values go in `~/.claude.json` (user-level config, not committed to version control)
153
+ - Tell the user how to configure each secret:
154
+ ```
155
+ claude config set env.VAR_NAME "actual-value"
156
+ ```
157
+
158
+ ### Safe to commit
159
+ - `.mcp.json` is safe to commit to version control — it contains only placeholders, never real secrets
160
+ - Add `.mcp.json` to the git commit alongside other Claude Code config files
161
+
162
+ ### Database safety
163
+ - Prefer read-only database connection strings
164
+ - If read-write access is needed, document this clearly in the recommendation
165
+
166
+ ### Principle of least privilege
167
+ - Only recommend servers that the project actually needs
168
+ - Prefer servers with narrow, well-defined capabilities over general-purpose ones