claudenv 1.1.0 → 1.2.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/README.md CHANGED
@@ -27,15 +27,18 @@ Claude AI will:
27
27
  2. Detect your tech stack, frameworks, and tooling
28
28
  3. Ask you about the project (description, deployment, conventions)
29
29
  4. Generate all documentation files
30
- 5. Install slash commands for ongoing maintenance
30
+ 5. Search the [MCP Registry](https://registry.modelcontextprotocol.io) and configure MCP servers
31
+ 6. Install slash commands for ongoing maintenance
31
32
 
32
- **Step 3.** You now have three commands available in Claude Code:
33
+ You now have five commands available in Claude Code:
33
34
 
34
35
  | Command | What it does |
35
36
  |---------|-------------|
36
37
  | `/init-docs` | Regenerate documentation from scratch |
37
38
  | `/update-docs` | Scan for changes and propose updates |
38
39
  | `/validate-docs` | Check that documentation is complete and correct |
40
+ | `/setup-mcp` | Recommend and configure MCP servers |
41
+ | `/improve` | Analyze and make one improvement |
39
42
 
40
43
  ## What Gets Generated
41
44
 
@@ -43,6 +46,7 @@ Claude AI will:
43
46
  your-project/
44
47
  ├── CLAUDE.md # Project overview, commands, architecture
45
48
  ├── _state.md # Session memory (decisions, focus, issues)
49
+ ├── .mcp.json # MCP server configuration
46
50
  └── .claude/
47
51
  ├── rules/
48
52
  │ ├── code-style.md # Coding conventions (scoped by file paths)
@@ -52,7 +56,9 @@ your-project/
52
56
  ├── commands/
53
57
  │ ├── init-docs.md # /init-docs
54
58
  │ ├── update-docs.md # /update-docs
55
- └── validate-docs.md # /validate-docs
59
+ ├── validate-docs.md # /validate-docs
60
+ │ ├── setup-mcp.md # /setup-mcp
61
+ │ └── improve.md # /improve
56
62
  ├── skills/
57
63
  │ └── doc-generator/ # Auto-triggers when docs need updating
58
64
  └── agents/
@@ -68,6 +74,145 @@ your-project/
68
74
  | `.claude/rules/workflow.md` | Best practices: plan mode, `/compact`, subagents, git discipline |
69
75
  | `.claude/rules/code-style.md` | Language and framework-specific coding conventions |
70
76
  | `.claude/rules/testing.md` | Test framework patterns and commands |
77
+ | `.mcp.json` | MCP server configuration with `${ENV_VAR}` placeholders |
78
+
79
+ ## MCP Server Recommendations
80
+
81
+ `/claudenv` automatically recommends MCP servers based on your tech stack. You can also run `/setup-mcp` independently at any time.
82
+
83
+ **How it works:**
84
+
85
+ 1. Claude analyzes your project's dependencies, databases, cloud services, and tools
86
+ 2. Searches the [official MCP Registry](https://registry.modelcontextprotocol.io) for matching servers
87
+ 3. Verifies trust via npm download counts (filters out servers with <100 monthly downloads)
88
+ 4. Presents recommendations grouped as **Essential** / **Recommended** / **Optional**
89
+ 5. Generates `.mcp.json` with selected servers
90
+
91
+ **Example output** (`.mcp.json`):
92
+
93
+ ```json
94
+ {
95
+ "mcpServers": {
96
+ "context7": {
97
+ "command": "npx",
98
+ "args": ["-y", "@upstash/context7-mcp@latest"],
99
+ "env": {}
100
+ },
101
+ "postgres": {
102
+ "command": "npx",
103
+ "args": ["-y", "@modelcontextprotocol/server-postgres@latest", "${POSTGRES_CONNECTION_STRING}"],
104
+ "env": {}
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ Secrets use `${ENV_VAR}` placeholders — configure them with:
111
+
112
+ ```bash
113
+ claude config set env.POSTGRES_CONNECTION_STRING "postgresql://..."
114
+ ```
115
+
116
+ `.mcp.json` is safe to commit — it never contains actual secrets.
117
+
118
+ Run `/setup-mcp --force` to auto-select Essential + Recommended servers without prompting.
119
+
120
+ ## Iterative Improvement Loop
121
+
122
+ `claudenv loop` spawns Claude Code in headless mode to analyze and improve your project iteratively. Each run creates a git safety tag so you can always rollback.
123
+
124
+ **How it works:**
125
+
126
+ 1. **Planning** (iteration 0) — Claude analyzes the project and generates `.claude/improvement-plan.md` with prioritized hypotheses
127
+ 2. **Execution** (iterations 1-N) — each iteration picks the top unfinished item from the plan, implements it, runs tests, and commits
128
+ 3. **Convergence** — the loop stops when the plan is complete, max iterations are reached, or the loop detects it's stuck
129
+
130
+ **Usage:**
131
+
132
+ ```bash
133
+ claudenv loop # Interactive, pauses between iterations
134
+ claudenv loop --trust # Full trust, no pauses, no permission prompts
135
+ claudenv loop --trust -n 5 # 5 iterations in full trust
136
+ claudenv loop --goal "add test coverage" # Focused improvement
137
+ claudenv loop --trust --model opus -n 3 # Use Opus, 3 iterations
138
+ claudenv loop --budget 1.00 -n 10 # Budget cap per iteration
139
+ claudenv loop --rollback # Undo all loop changes
140
+ ```
141
+
142
+ | Flag | Description |
143
+ |------|-------------|
144
+ | `-n, --iterations <n>` | Max iterations (default: unlimited) |
145
+ | `--trust` | Full trust mode — no pauses, skip permission prompts |
146
+ | `--goal <text>` | Focus area for improvements |
147
+ | `--profile <name>` | Autonomy profile: safe, moderate, full, ci |
148
+ | `--no-pause` | Don't pause between iterations |
149
+ | `--max-turns <n>` | Max agentic turns per iteration (default: 30) |
150
+ | `--model <model>` | Model to use (default: sonnet) |
151
+ | `--budget <usd>` | Budget cap per iteration in USD |
152
+ | `-d, --dir <path>` | Target project directory |
153
+ | `--allow-dirty` | Allow running with uncommitted changes |
154
+ | `--rollback` | Undo all changes from the most recent loop |
155
+ | `--unsafe` | Remove default tool restrictions |
156
+
157
+ **Git safety:** Before the first iteration, a `claudenv-loop-<timestamp>` git tag is created. Each iteration commits separately. Use `claudenv loop --rollback` to reset everything, or cherry-pick individual commits.
158
+
159
+ **Single iteration:** Use `/improve` inside Claude Code for a one-shot improvement without the full loop.
160
+
161
+ ## Autonomous Agent Mode
162
+
163
+ `claudenv autonomy` configures Claude Code for autonomous operation with predefined security profiles. Inspired by [trailofbits/claude-code-config](https://github.com/trailofbits/claude-code-config).
164
+
165
+ **Usage:**
166
+
167
+ ```bash
168
+ claudenv autonomy # Interactive profile selection
169
+ claudenv autonomy --profile moderate # Non-interactive, writes files directly
170
+ claudenv autonomy --profile moderate -y # Same — -y only needed for profile selection
171
+ claudenv autonomy --profile ci --dry-run # Preview generated files
172
+ claudenv autonomy --profile full # Full autonomy — requires typing "full" to confirm
173
+ claudenv autonomy --profile full --yes # Full autonomy, skip confirmation
174
+ ```
175
+
176
+ ### Profiles
177
+
178
+ | Profile | Description | Permissions | Credentials |
179
+ |---------|-------------|-------------|-------------|
180
+ | `safe` | Read-only + limited bash | Allow-list only | Blocked |
181
+ | `moderate` | Full dev with deny-list | Allow + deny lists | Blocked |
182
+ | `full` | Unrestricted + audit logging | `--dangerously-skip-permissions` | Warn-only |
183
+ | `ci` | Headless CI/CD (50 turns, $5 budget) | `--dangerously-skip-permissions` | Warn-only |
184
+
185
+ All profiles hard-block `rm -rf`, force push to main/master, and `sudo`.
186
+
187
+ ### Generated files
188
+
189
+ ```
190
+ .claude/
191
+ ├── settings.json # Permissions + hooks config
192
+ ├── hooks/
193
+ │ ├── pre-tool-use.sh # PreToolUse guard (blocks dangerous ops)
194
+ │ └── audit-log.sh # PostToolUse audit → audit-log.jsonl
195
+ └── aliases.sh # Shell aliases: claude-safe, claude-yolo, claude-ci, claude-local
196
+ ```
197
+
198
+ CI profile also generates `.github/workflows/claude-ci.yml`.
199
+
200
+ ### Loop integration
201
+
202
+ Use `--profile` with `claudenv loop` to apply profile settings:
203
+
204
+ ```bash
205
+ claudenv loop --profile moderate --goal "add types" # Uses profile's deny-list
206
+ claudenv loop --profile ci -n 5 # CI defaults: 50 turns, $5 budget
207
+ ```
208
+
209
+ | Flag | Description |
210
+ |------|-------------|
211
+ | `-p, --profile <name>` | Profile: safe, moderate, full, ci |
212
+ | `-d, --dir <path>` | Project directory (default: `.`) |
213
+ | `--overwrite` | Overwrite existing files |
214
+ | `-y, --yes` | Skip prompts |
215
+ | `--dry-run` | Preview without writing |
71
216
 
72
217
  ## Tech Stack Detection
73
218
 
@@ -83,14 +228,21 @@ Claude AI reads your actual code, but the following are auto-detected for contex
83
228
  ## CLI Reference
84
229
 
85
230
  ```
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
231
+ claudenv Install /claudenv into ~/.claude/ (default)
232
+ claudenv install Same as above (explicit)
233
+ claudenv install -f Reinstall, overwriting existing files
234
+ claudenv uninstall Remove /claudenv from ~/.claude/
235
+ claudenv init [dir] Legacy: static analysis + terminal prompts (no AI)
236
+ claudenv init -y Legacy: skip prompts, auto-detect everything
237
+ claudenv generate Templates only, no scaffold
238
+ claudenv validate Check documentation completeness
239
+ claudenv loop Iterative improvement loop (spawns Claude)
240
+ claudenv loop --trust Full trust mode, no pauses
241
+ claudenv loop --profile moderate Use autonomy profile in loop
242
+ claudenv loop --rollback Undo all loop changes
243
+ claudenv autonomy Configure autonomous agent mode (interactive)
244
+ claudenv autonomy -p moderate Apply moderate profile
245
+ claudenv autonomy -p ci --dry-run Preview CI config without writing
94
246
  ```
95
247
 
96
248
  ## Alternative: Run Without Installing
package/bin/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { Command } from 'commander';
4
4
  import { resolve, join } from 'node:path';
5
- import { readFile } from 'node:fs/promises';
5
+ import { readFile, chmod } from 'node:fs/promises';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { dirname } from 'node:path';
8
8
  import { detectTechStack } from '../src/detector.js';
@@ -10,6 +10,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
12
  import { installGlobal, uninstallGlobal } from '../src/installer.js';
13
+ import { runLoop, rollback, checkClaudeCli } from '../src/loop.js';
14
+ import { generateAutonomyConfig, printSecuritySummary, getFullModeWarning } from '../src/autonomy.js';
15
+ import { getProfile, listProfiles } from '../src/profiles.js';
13
16
 
14
17
  const __dirname = dirname(fileURLToPath(import.meta.url));
15
18
  const pkgJson = JSON.parse(await readFile(join(__dirname, '..', 'package.json'), 'utf-8'));
@@ -113,6 +116,95 @@ program
113
116
  }
114
117
  });
115
118
 
119
+ // --- loop ---
120
+ program
121
+ .command('loop')
122
+ .description('Iterative improvement loop — spawn Claude to analyze and improve the project')
123
+ .option('-n, --iterations <n>', 'Max iterations (default: unlimited)', parseInt)
124
+ .option('--trust', 'Full trust mode — no pauses, no permission prompts')
125
+ .option('--goal <text>', 'Focus area for improvements')
126
+ .option('--pause', 'Pause between iterations (default: on unless --trust)')
127
+ .option('--no-pause', 'Do not pause between iterations')
128
+ .option('--max-turns <n>', 'Max agentic turns per iteration (default: 30)', parseInt)
129
+ .option('--model <model>', 'Model to use (default: sonnet)')
130
+ .option('--budget <usd>', 'Budget cap per iteration in USD', parseFloat)
131
+ .option('-d, --dir <path>', 'Target project directory')
132
+ .option('--allow-dirty', 'Allow running with uncommitted git changes')
133
+ .option('--rollback', 'Undo all changes from the most recent loop run')
134
+ .option('--unsafe', 'Remove default tool restrictions (allows rm -rf)')
135
+ .option('--worktree', 'Run each iteration in an isolated git worktree')
136
+ .option('--profile <name>', 'Autonomy profile: safe, moderate, full, ci')
137
+ .action(async (opts) => {
138
+ // --- Rollback mode ---
139
+ if (opts.rollback) {
140
+ await rollback({ cwd: opts.dir ? resolve(opts.dir) : process.cwd() });
141
+ return;
142
+ }
143
+
144
+ // --- Pre-flight: check Claude CLI ---
145
+ const cli = checkClaudeCli();
146
+ if (!cli.installed) {
147
+ console.error('\n Error: Claude CLI not found.');
148
+ console.error(' Install it from https://docs.anthropic.com/en/docs/claude-code\n');
149
+ process.exit(1);
150
+ }
151
+ console.log(`\n claudenv loop v${pkgJson.version}`);
152
+ console.log(` Claude CLI: ${cli.version}`);
153
+
154
+ // --- Load profile if specified ---
155
+ let profileDefaults = {};
156
+ if (opts.profile) {
157
+ const profile = getProfile(opts.profile);
158
+ profileDefaults = {
159
+ trust: profile.skipPermissions,
160
+ disallowedTools: profile.disallowedTools,
161
+ maxTurns: profile.maxTurns,
162
+ budget: profile.maxBudget,
163
+ };
164
+ console.log(` Profile: ${profile.name} — ${profile.description}`);
165
+ }
166
+
167
+ // --- Config summary ---
168
+ const cwd = opts.dir ? resolve(opts.dir) : process.cwd();
169
+ const trust = opts.trust || profileDefaults.trust || false;
170
+ const pause = opts.pause !== undefined ? opts.pause : !trust;
171
+
172
+ console.log(` Directory: ${cwd}`);
173
+ console.log(` Mode: ${trust ? 'full trust (--dangerously-skip-permissions)' : 'interactive'}`);
174
+ if (opts.worktree) console.log(` Worktree: enabled (each iteration in isolated worktree)`);
175
+ if (opts.iterations) console.log(` Max iterations: ${opts.iterations}`);
176
+ if (opts.goal) console.log(` Goal: ${opts.goal}`);
177
+ if (opts.model) console.log(` Model: ${opts.model}`);
178
+ if (opts.budget || profileDefaults.budget) console.log(` Budget: $${opts.budget || profileDefaults.budget}/iteration`);
179
+ if (opts.maxTurns || profileDefaults.maxTurns) console.log(` Max turns: ${opts.maxTurns || profileDefaults.maxTurns}`);
180
+
181
+ await runLoop({
182
+ iterations: opts.iterations,
183
+ trust,
184
+ goal: opts.goal,
185
+ pause,
186
+ maxTurns: opts.maxTurns || profileDefaults.maxTurns || 30,
187
+ model: opts.model,
188
+ budget: opts.budget || profileDefaults.budget,
189
+ cwd,
190
+ allowDirty: opts.allowDirty || false,
191
+ unsafe: opts.unsafe || false,
192
+ worktree: opts.worktree || false,
193
+ disallowedTools: profileDefaults.disallowedTools,
194
+ });
195
+ });
196
+
197
+ // --- autonomy ---
198
+ program
199
+ .command('autonomy')
200
+ .description('Configure autonomous agent mode with safety guardrails')
201
+ .option('-p, --profile <name>', 'Profile: safe, moderate, full, ci')
202
+ .option('-d, --dir <path>', 'Project directory', '.')
203
+ .option('--overwrite', 'Overwrite existing files')
204
+ .option('-y, --yes', 'Skip prompts')
205
+ .option('--dry-run', 'Preview without writing')
206
+ .action(runAutonomy);
207
+
116
208
  // =============================================
117
209
  // Install / Uninstall
118
210
  // =============================================
@@ -263,4 +355,81 @@ function printValidation(label, result) {
263
355
  }
264
356
  }
265
357
 
358
+ // =============================================
359
+ // Autonomy
360
+ // =============================================
361
+ async function runAutonomy(opts) {
362
+ const { select, input } = await import('@inquirer/prompts');
363
+ const projectDir = resolve(opts.dir);
364
+
365
+ console.log(`\n claudenv autonomy v${pkgJson.version}\n`);
366
+
367
+ // --- Profile selection ---
368
+ let profileName = opts.profile;
369
+ if (!profileName && !opts.yes) {
370
+ const profiles = listProfiles();
371
+ profileName = await select({
372
+ message: 'Select autonomy profile:',
373
+ choices: profiles.map((p) => ({
374
+ name: `${p.name} — ${p.description}`,
375
+ value: p.name,
376
+ })),
377
+ });
378
+ } else if (!profileName) {
379
+ profileName = 'moderate';
380
+ }
381
+
382
+ // --- Full mode confirmation ---
383
+ if (profileName === 'full') {
384
+ console.log(getFullModeWarning());
385
+ if (!opts.yes) {
386
+ const confirm = await input({ message: 'Type "full" to confirm:' });
387
+ if (confirm.trim() !== 'full') {
388
+ console.log(' Cancelled.\n');
389
+ return;
390
+ }
391
+ } else {
392
+ console.log(' --yes flag set, proceeding without confirmation.\n');
393
+ }
394
+ }
395
+
396
+ // --- Generate files ---
397
+ const { files, profile } = await generateAutonomyConfig(profileName, projectDir);
398
+
399
+ printSecuritySummary(profile);
400
+
401
+ if (opts.dryRun) {
402
+ console.log(' Dry run — files that would be generated:\n');
403
+ for (const f of files) {
404
+ console.log(` ── ${f.path} ──`);
405
+ console.log(f.content);
406
+ }
407
+ return;
408
+ }
409
+
410
+ // --- Write files ---
411
+ const { written, skipped } = await writeDocs(projectDir, files, {
412
+ overwrite: opts.overwrite || false,
413
+ });
414
+
415
+ // Make hook scripts executable
416
+ for (const f of files) {
417
+ if (f.path.endsWith('.sh')) {
418
+ try {
419
+ await chmod(join(projectDir, f.path), 0o755);
420
+ } catch { /* ignore */ }
421
+ }
422
+ }
423
+
424
+ printFileResults(written, skipped);
425
+
426
+ console.log(`
427
+ Next steps:
428
+ 1. Review .claude/settings.json
429
+ 2. Source aliases: source .claude/aliases.sh
430
+ 3. ${profile.skipPermissions ? 'Run: claude --dangerously-skip-permissions' : 'Run: claude'}
431
+ 4. git add .claude/ && git commit -m "Add autonomy config (${profileName})"
432
+ `);
433
+ }
434
+
266
435
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudenv",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
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": {
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: hypothesis-tester
3
+ description: Tests implementation hypotheses in isolation. Use when exploring risky refactors, alternative approaches, or when the current approach might need rollback.
4
+ tools: Read, Write, Edit, Glob, Grep, Bash
5
+ model: sonnet
6
+ ---
7
+
8
+ You are testing an implementation hypothesis in an isolated git worktree.
9
+
10
+ ## Your workflow
11
+ 1. Read the parent branch context (goal, constraints, current state)
12
+ 2. Implement the hypothesis
13
+ 3. Run tests to validate
14
+ 4. If tests pass — commit with descriptive message, report SUCCESS
15
+ 5. If tests fail — report FAILURE with analysis of why, do NOT commit broken code
16
+
17
+ ## Output format
18
+ Report exactly one of:
19
+ - `HYPOTHESIS_SUCCESS: <summary of what worked and why>`
20
+ - `HYPOTHESIS_FAILURE: <summary of what failed and why>`
21
+
22
+ The parent agent will decide whether to merge your worktree branch.
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: rollback-analyzer
3
+ description: Analyzes past hypothesis branches to understand what was tried and why it failed. Use before retrying a failed approach.
4
+ tools: Read, Glob, Grep, Bash
5
+ model: haiku
6
+ ---
7
+
8
+ You analyze past hypothesis branches to help the parent agent avoid repeating mistakes.
9
+
10
+ ## Your workflow
11
+ 1. List branches: `git branch -l "claudenv/*"`
12
+ 2. For each relevant branch, show: `git log --oneline <parent>..claudenv/<name>`
13
+ 3. Read key changed files: `git diff <parent>...claudenv/<name> --stat`
14
+ 4. Summarize: what was tried, what failed, what can be learned
15
+
16
+ ## Output format
17
+ For each hypothesis branch:
18
+ - **Branch:** claudenv/<name>
19
+ - **Goal:** <extracted from commit messages>
20
+ - **Changes:** <file summary>
21
+ - **Result:** SUCCESS/FAILURE
22
+ - **Lesson:** <what to do differently>
@@ -0,0 +1,60 @@
1
+ ---
2
+ description: Analyze this project and make one high-impact improvement — fix bugs, add tests, improve code quality
3
+ allowed-tools: Read, Write, Glob, Grep, Bash
4
+ argument-hint: [area-to-improve]
5
+ ---
6
+
7
+ # /improve — Single Improvement Iteration
8
+
9
+ You are an expert software engineer. Your job is to analyze this project and make one high-impact improvement.
10
+
11
+ ## Step 1: Read Context
12
+
13
+ Read these files if they exist:
14
+ - `CLAUDE.md` — project overview and conventions
15
+ - `_state.md` — session memory
16
+ - `.claude/improvement-plan.md` — existing improvement plan (if any)
17
+
18
+ ## Step 2: Choose What to Improve
19
+
20
+ **If `.claude/improvement-plan.md` exists:**
21
+ - Read the plan and pick the top unfinished item from the "## Pending" section
22
+ - If `$ARGUMENTS` is provided, use it as a focus area instead of the plan
23
+
24
+ **If no plan exists:**
25
+ - Analyze the project: read manifest files, scan source code, check test coverage
26
+ - If `$ARGUMENTS` is provided, focus on that area
27
+ - Identify the single highest-impact improvement you can make
28
+
29
+ ## Step 3: Implement the Change
30
+
31
+ - Write the code changes
32
+ - Add or update tests if applicable
33
+ - Follow existing code style and conventions
34
+
35
+ ## Step 4: Verify
36
+
37
+ - Run tests (if a test command is available)
38
+ - Run linter (if configured)
39
+ - Fix any issues found
40
+
41
+ ## Step 5: Update Plan
42
+
43
+ If `.claude/improvement-plan.md` exists:
44
+ - Move the completed item from "## Pending" to "## Completed"
45
+ - Add the commit hash and notes about what was done
46
+ - If you discovered new issues, add them to "## Pending"
47
+
48
+ ## Step 6: Commit and Report
49
+
50
+ - Commit all changes with a descriptive message
51
+ - Report:
52
+ - What you changed and why
53
+ - What tests were added/updated
54
+ - What's next (remaining plan items or suggested improvements)
55
+
56
+ ## Important Rules
57
+
58
+ - Do NOT delete files unless the deletion IS the improvement
59
+ - Make exactly ONE improvement per invocation
60
+ - If there's nothing left to improve, output: NO_MORE_IMPROVEMENTS
@@ -107,6 +107,7 @@ cp ~/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/scripts/valid
107
107
  cp ~/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/templates/detection-patterns.md .claude/skills/doc-generator/templates/detection-patterns.md
108
108
  cp ~/.claude/skills/claudenv/scaffold/.claude/skills/doc-generator/templates/mcp-servers.md .claude/skills/doc-generator/templates/mcp-servers.md
109
109
  cp ~/.claude/skills/claudenv/scaffold/.claude/commands/setup-mcp.md .claude/commands/setup-mcp.md
110
+ cp ~/.claude/skills/claudenv/scaffold/.claude/commands/improve.md .claude/commands/improve.md
110
111
  cp ~/.claude/skills/claudenv/scaffold/.claude/agents/doc-analyzer.md .claude/agents/doc-analyzer.md
111
112
  chmod +x .claude/skills/doc-generator/scripts/validate.sh
112
113
  ```
@@ -176,6 +177,7 @@ Created:
176
177
  + .claude/commands/update-docs.md
177
178
  + .claude/commands/validate-docs.md
178
179
  + .claude/commands/setup-mcp.md
180
+ + .claude/commands/improve.md
179
181
  + .claude/skills/doc-generator/
180
182
  + .claude/agents/doc-analyzer.md
181
183
  + .mcp.json (if MCP servers were configured)
@@ -185,6 +187,7 @@ Available commands:
185
187
  /update-docs — Update docs when project changes
186
188
  /validate-docs — Check documentation completeness
187
189
  /setup-mcp — Add or update MCP server configuration
190
+ /improve — Analyze and make one improvement
188
191
 
189
192
  Next steps:
190
193
  1. Review and edit CLAUDE.md
@@ -55,5 +55,6 @@ The following files are available for installation into projects at `~/.claude/s
55
55
  - `.claude/skills/doc-generator/scripts/validate.sh` — Bash validation script
56
56
  - `.claude/skills/doc-generator/templates/detection-patterns.md` — Detection reference
57
57
  - `.claude/commands/setup-mcp.md` — MCP server recommendation and setup
58
+ - `.claude/commands/improve.md` — Single improvement iteration (used by claudenv loop)
58
59
  - `.claude/skills/doc-generator/templates/mcp-servers.md` — MCP registry reference
59
60
  - `.claude/agents/doc-analyzer.md` — Read-only analysis subagent
@@ -0,0 +1,60 @@
1
+ ---
2
+ description: Analyze this project and make one high-impact improvement — fix bugs, add tests, improve code quality
3
+ allowed-tools: Read, Write, Glob, Grep, Bash
4
+ argument-hint: [area-to-improve]
5
+ ---
6
+
7
+ # /improve — Single Improvement Iteration
8
+
9
+ You are an expert software engineer. Your job is to analyze this project and make one high-impact improvement.
10
+
11
+ ## Step 1: Read Context
12
+
13
+ Read these files if they exist:
14
+ - `CLAUDE.md` — project overview and conventions
15
+ - `_state.md` — session memory
16
+ - `.claude/improvement-plan.md` — existing improvement plan (if any)
17
+
18
+ ## Step 2: Choose What to Improve
19
+
20
+ **If `.claude/improvement-plan.md` exists:**
21
+ - Read the plan and pick the top unfinished item from the "## Pending" section
22
+ - If `$ARGUMENTS` is provided, use it as a focus area instead of the plan
23
+
24
+ **If no plan exists:**
25
+ - Analyze the project: read manifest files, scan source code, check test coverage
26
+ - If `$ARGUMENTS` is provided, focus on that area
27
+ - Identify the single highest-impact improvement you can make
28
+
29
+ ## Step 3: Implement the Change
30
+
31
+ - Write the code changes
32
+ - Add or update tests if applicable
33
+ - Follow existing code style and conventions
34
+
35
+ ## Step 4: Verify
36
+
37
+ - Run tests (if a test command is available)
38
+ - Run linter (if configured)
39
+ - Fix any issues found
40
+
41
+ ## Step 5: Update Plan
42
+
43
+ If `.claude/improvement-plan.md` exists:
44
+ - Move the completed item from "## Pending" to "## Completed"
45
+ - Add the commit hash and notes about what was done
46
+ - If you discovered new issues, add them to "## Pending"
47
+
48
+ ## Step 6: Commit and Report
49
+
50
+ - Commit all changes with a descriptive message
51
+ - Report:
52
+ - What you changed and why
53
+ - What tests were added/updated
54
+ - What's next (remaining plan items or suggested improvements)
55
+
56
+ ## Important Rules
57
+
58
+ - Do NOT delete files unless the deletion IS the improvement
59
+ - Make exactly ONE improvement per invocation
60
+ - If there's nothing left to improve, output: NO_MORE_IMPROVEMENTS