@paulduvall/claude-dev-toolkit 0.0.1-alpha.11 → 0.0.1-alpha.13
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 +7 -7
- package/bin/claude-commands +72 -9
- package/commands/active/xcontinue.md +92 -0
- package/commands/active/xexplore.md +94 -0
- package/commands/active/xverify.md +80 -0
- package/commands/experiments/xdevcontainer.md +238 -0
- package/commands/experiments/xnew.md +5 -0
- package/hooks/README.md +32 -0
- package/hooks/file-logger.sh +4 -2
- package/hooks/lib/argument-parser.sh +7 -2
- package/hooks/lib/config-constants.sh +4 -4
- package/hooks/lib/context-manager.sh +19 -8
- package/hooks/lib/error-handler.sh +21 -10
- package/hooks/lib/execution-engine.sh +11 -194
- package/hooks/lib/execution-results.sh +113 -0
- package/hooks/lib/execution-simulation.sh +114 -0
- package/hooks/lib/field-validators.sh +104 -0
- package/hooks/lib/file-utils.sh +49 -26
- package/hooks/lib/subagent-discovery.sh +9 -6
- package/hooks/lib/subagent-validator.sh +19 -209
- package/hooks/lib/validation-reporter.sh +134 -0
- package/hooks/on-error-debug.sh +16 -11
- package/hooks/pre-commit-test-runner.sh +132 -0
- package/hooks/pre-write-security.sh +14 -6
- package/hooks/prevent-credential-exposure.sh +55 -45
- package/hooks/subagent-trigger-simple.sh +17 -8
- package/hooks/verify-before-edit.sh +135 -0
- package/lib/oidc-command.js +385 -8
- package/lib/setup-wizard.js +155 -262
- package/lib/uninstall-command.js +100 -0
- package/package.json +2 -2
- package/scripts/postinstall.js +168 -171
- package/subagents/debug-specialist.md +6 -0
- package/templates/README.md +15 -0
- package/templates/basic-settings.json +33 -19
- package/templates/comprehensive-settings.json +68 -171
- package/templates/global-claude.md +344 -0
- package/templates/security-focused-settings.json +58 -41
- package/lib/installation-instruction-generator-backup.js +0 -579
- package/lib/package-manager-service.js +0 -270
- package/subagents/debug-context.md +0 -197
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Paul Duvall
|
|
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
CHANGED
|
@@ -20,7 +20,7 @@ claude
|
|
|
20
20
|
- **Security Hooks**: Automated security validation and governance
|
|
21
21
|
- **Configuration Templates**: Pre-configured settings for different workflows
|
|
22
22
|
- **Interactive Setup Wizard**: Guided installation with customization options
|
|
23
|
-
- **JavaScript Test Suite**:
|
|
23
|
+
- **JavaScript Test Suite**: 25 test suites validating package structure, commands, and integration
|
|
24
24
|
|
|
25
25
|
## 🎯 Quick Start
|
|
26
26
|
|
|
@@ -166,11 +166,11 @@ npm run lint # Code linting
|
|
|
166
166
|
```
|
|
167
167
|
|
|
168
168
|
### Test Coverage
|
|
169
|
-
- **
|
|
170
|
-
- **Command Validation**: All
|
|
171
|
-
- **Security Tests**:
|
|
172
|
-
- **Integration Tests**:
|
|
173
|
-
- **
|
|
169
|
+
- **25 Test Suites**: Package structure, CLI, and command validation
|
|
170
|
+
- **Command Validation**: All commands validated for structure and naming
|
|
171
|
+
- **Security Tests**: Credential exposure and placeholder detection
|
|
172
|
+
- **Integration Tests**: Hook and subagent workflow testing
|
|
173
|
+
- **Shell Tests**: 8 bash test suites for hooks and lib modules
|
|
174
174
|
|
|
175
175
|
### Architecture
|
|
176
176
|
- **Self-Contained Package**: No dependencies on repository cloning
|
|
@@ -288,7 +288,7 @@ npm test
|
|
|
288
288
|
- ✅ **Symlink Consolidation**: Eliminated duplicate directories
|
|
289
289
|
- ✅ **JavaScript Migration**: Complete test suite migration from Python
|
|
290
290
|
- ✅ **Enhanced Templates**: Fixed configuration template issues
|
|
291
|
-
- ✅ **
|
|
291
|
+
- ✅ **Test Suites**: Package structure and command validation
|
|
292
292
|
- ✅ **58 Total Commands**: 13 active + 45 experimental commands
|
|
293
293
|
- ✅ **Security Enhancements**: Comprehensive security hook system
|
|
294
294
|
|
package/bin/claude-commands
CHANGED
|
@@ -19,36 +19,75 @@ program
|
|
|
19
19
|
program
|
|
20
20
|
.command('list')
|
|
21
21
|
.description('List all available commands')
|
|
22
|
+
.addHelpText('after', `
|
|
23
|
+
Examples:
|
|
24
|
+
$ claude-commands list # List all installed commands
|
|
25
|
+
$ claude-commands list --active # Show only production commands
|
|
26
|
+
$ claude-commands list --experiments # Show only experimental commands`)
|
|
22
27
|
.option('-a, --active', 'Show only active commands')
|
|
23
28
|
.option('-e, --experiments', 'Show only experimental commands')
|
|
24
29
|
.action((options) => {
|
|
25
30
|
const claudeDir = path.join(os.homedir(), '.claude', 'commands');
|
|
26
|
-
|
|
31
|
+
const pkgDir = path.join(__dirname, '..', 'commands');
|
|
32
|
+
|
|
27
33
|
console.log('📦 Claude Custom Commands\n');
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
|
|
35
|
+
// Determine source: installed commands or package commands
|
|
36
|
+
const sourceDir = fs.existsSync(claudeDir) ? claudeDir : null;
|
|
37
|
+
|
|
38
|
+
if (sourceDir) {
|
|
39
|
+
let allCommands = fs.readdirSync(sourceDir)
|
|
31
40
|
.filter(f => f.endsWith('.md'))
|
|
32
41
|
.map(f => f.replace('.md', ''))
|
|
33
42
|
.sort();
|
|
34
|
-
|
|
43
|
+
|
|
44
|
+
// Apply --active/--experiments filters using package source dirs
|
|
45
|
+
if (options.active || options.experiments) {
|
|
46
|
+
const activeDir = path.join(pkgDir, 'active');
|
|
47
|
+
const expDir = path.join(pkgDir, 'experiments');
|
|
48
|
+
const activeSet = new Set();
|
|
49
|
+
const expSet = new Set();
|
|
50
|
+
|
|
51
|
+
if (fs.existsSync(activeDir)) {
|
|
52
|
+
fs.readdirSync(activeDir)
|
|
53
|
+
.filter(f => f.endsWith('.md'))
|
|
54
|
+
.forEach(f => activeSet.add(f.replace('.md', '')));
|
|
55
|
+
}
|
|
56
|
+
if (fs.existsSync(expDir)) {
|
|
57
|
+
fs.readdirSync(expDir)
|
|
58
|
+
.filter(f => f.endsWith('.md'))
|
|
59
|
+
.forEach(f => expSet.add(f.replace('.md', '')));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (options.active) {
|
|
63
|
+
allCommands = allCommands.filter(cmd => activeSet.has(cmd));
|
|
64
|
+
} else if (options.experiments) {
|
|
65
|
+
allCommands = allCommands.filter(cmd => expSet.has(cmd));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
35
69
|
if (allCommands.length > 0) {
|
|
36
|
-
|
|
70
|
+
const label = options.active ? 'Active' : options.experiments ? 'Experimental' : 'Available';
|
|
71
|
+
console.log(`🚀 ${label} Commands:`);
|
|
37
72
|
allCommands.forEach(cmd => console.log(` /${cmd}`));
|
|
38
73
|
console.log(`\n📊 Total: ${allCommands.length} commands`);
|
|
39
74
|
} else {
|
|
40
|
-
console.log(' No commands found');
|
|
75
|
+
console.log(' No commands found matching filter');
|
|
41
76
|
}
|
|
42
77
|
} else {
|
|
43
78
|
console.log(' Commands directory not found');
|
|
79
|
+
console.log(' Run: claude-commands install');
|
|
44
80
|
}
|
|
45
|
-
|
|
46
|
-
console.log('\n💡 Usage: Try /xhelp in Claude Code to see all commands');
|
|
47
81
|
});
|
|
48
82
|
|
|
49
83
|
program
|
|
50
84
|
.command('install')
|
|
51
85
|
.description('Install command sets to ~/.claude/commands/')
|
|
86
|
+
.addHelpText('after', `
|
|
87
|
+
Examples:
|
|
88
|
+
$ claude-commands install # Install active commands (default)
|
|
89
|
+
$ claude-commands install --all # Install all commands
|
|
90
|
+
$ claude-commands install --dry-run # Preview without changes`)
|
|
52
91
|
.option('--active', 'Install production-ready commands (default)')
|
|
53
92
|
.option('--experiments', 'Install experimental commands only')
|
|
54
93
|
.option('--all', 'Install both active and experimental')
|
|
@@ -153,6 +192,11 @@ program
|
|
|
153
192
|
program
|
|
154
193
|
.command('setup')
|
|
155
194
|
.description('Setup the Claude Dev Toolkit with custom commands and configuration')
|
|
195
|
+
.addHelpText('after', `
|
|
196
|
+
Examples:
|
|
197
|
+
$ claude-commands setup # Interactive setup
|
|
198
|
+
$ claude-commands setup --type basic --commands all # Basic config, all commands
|
|
199
|
+
$ claude-commands setup --dry-run # Preview setup actions`)
|
|
156
200
|
.option('--type <template>', 'Configuration template to apply (basic, comprehensive, security-focused)')
|
|
157
201
|
.option('--commands <set>', 'Command set to install (active, experiments, all, none)')
|
|
158
202
|
.option('--skip-configure', 'Skip configuration step')
|
|
@@ -328,4 +372,23 @@ program
|
|
|
328
372
|
}
|
|
329
373
|
});
|
|
330
374
|
|
|
375
|
+
program
|
|
376
|
+
.command('uninstall')
|
|
377
|
+
.description('Remove all installed commands, hooks, and subagents')
|
|
378
|
+
.addHelpText('after', `
|
|
379
|
+
Examples:
|
|
380
|
+
$ claude-commands uninstall # Remove all installed files
|
|
381
|
+
$ claude-commands uninstall --dry-run # Preview what would be removed`)
|
|
382
|
+
.option('--dry-run', 'Preview what would be removed without deleting')
|
|
383
|
+
.option('--keep-settings', 'Keep settings.json intact')
|
|
384
|
+
.action((options) => {
|
|
385
|
+
const uninstaller = require('../lib/uninstall-command');
|
|
386
|
+
try {
|
|
387
|
+
uninstaller.execute(options);
|
|
388
|
+
} catch (error) {
|
|
389
|
+
console.error(`Uninstall failed: ${error.message}`);
|
|
390
|
+
process.exit(1);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
|
|
331
394
|
program.parse(process.argv);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Continue an execution plan from where it left off across sessions
|
|
3
|
+
tags: [workflow, execution-plan, session-continuity, automation]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Execution Plan Continuation
|
|
7
|
+
|
|
8
|
+
Resume a multi-step execution plan, picking up at the next incomplete task.
|
|
9
|
+
|
|
10
|
+
## Usage Examples
|
|
11
|
+
|
|
12
|
+
**Resume the current plan:**
|
|
13
|
+
```
|
|
14
|
+
/xcontinue
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Help and options:**
|
|
18
|
+
```
|
|
19
|
+
/xcontinue help
|
|
20
|
+
/xcontinue --help
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Implementation
|
|
24
|
+
|
|
25
|
+
If $ARGUMENTS contains "help" or "--help":
|
|
26
|
+
Display this usage information and exit.
|
|
27
|
+
|
|
28
|
+
### Step 1: Find the Execution Plan
|
|
29
|
+
|
|
30
|
+
Search for execution plan files in the current directory:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
find . -maxdepth 2 -iname "*plan*" -name "*.md" ! -path "*/node_modules/*" ! -path "*/.git/*" 2>/dev/null
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- Common names: `EXECUTION_PLAN.md`, `PLAN.md`, `execution-plan.md`
|
|
37
|
+
|
|
38
|
+
If no plan file is found:
|
|
39
|
+
- Tell the user: "No execution plan found in this directory."
|
|
40
|
+
- Suggest creating one with a basic template:
|
|
41
|
+
|
|
42
|
+
```markdown
|
|
43
|
+
# Execution Plan
|
|
44
|
+
|
|
45
|
+
| # | Task | Status | Notes |
|
|
46
|
+
|---|------|--------|-------|
|
|
47
|
+
| 1 | [First task] | [ ] pending | |
|
|
48
|
+
| 2 | [Second task] | [ ] pending | |
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Stop and wait for user input.
|
|
52
|
+
|
|
53
|
+
### Step 2: Parse Plan Progress
|
|
54
|
+
|
|
55
|
+
Read the plan file and identify:
|
|
56
|
+
- **Completed tasks**: Lines with `[x]`, `done`, or checkmarks
|
|
57
|
+
- **Pending tasks**: Lines with `[ ]`, `pending`, or unchecked items
|
|
58
|
+
- **In-progress tasks**: Lines with `in-progress` or `in progress`
|
|
59
|
+
|
|
60
|
+
Display a progress summary:
|
|
61
|
+
```
|
|
62
|
+
Progress: X of Y tasks complete
|
|
63
|
+
Next task: [description of next pending task]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
If all tasks are complete:
|
|
67
|
+
- Congratulate the user
|
|
68
|
+
- Summarize what was accomplished
|
|
69
|
+
- Suggest cleanup: "Consider deleting the plan file if work is done."
|
|
70
|
+
- Stop execution.
|
|
71
|
+
|
|
72
|
+
### Step 3: Execute Next Task
|
|
73
|
+
|
|
74
|
+
Pick the first task with status `pending` or `[ ]`:
|
|
75
|
+
1. Read the task description and any acceptance criteria
|
|
76
|
+
2. Implement the task fully
|
|
77
|
+
3. Run validation if applicable (tests, lint, build)
|
|
78
|
+
4. Verify acceptance criteria pass
|
|
79
|
+
|
|
80
|
+
### Step 4: Update Plan and Handoff
|
|
81
|
+
|
|
82
|
+
After completing the task:
|
|
83
|
+
1. Update the plan file — mark the task as `[x] done` with a timestamp
|
|
84
|
+
2. Update any counters (Done/Remaining) in the plan header
|
|
85
|
+
3. Tell the user:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
Task #N complete: [brief summary]
|
|
89
|
+
Run /clear then /xcontinue to proceed to the next task.
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This handoff protocol ensures context stays fresh across sessions.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Explore a codebase topic before making changes (read-only)
|
|
3
|
+
tags: [exploration, codebase, discovery, read-only]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Codebase Exploration
|
|
7
|
+
|
|
8
|
+
Comprehensively search the codebase for a topic before making any changes. Read-only — no files are modified.
|
|
9
|
+
|
|
10
|
+
## Usage Examples
|
|
11
|
+
|
|
12
|
+
**Explore a topic:**
|
|
13
|
+
```
|
|
14
|
+
/xexplore authentication
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Explore a specific area:**
|
|
18
|
+
```
|
|
19
|
+
/xexplore database migrations
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Help and options:**
|
|
23
|
+
```
|
|
24
|
+
/xexplore help
|
|
25
|
+
/xexplore --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Implementation
|
|
29
|
+
|
|
30
|
+
If $ARGUMENTS contains "help" or "--help":
|
|
31
|
+
Display this usage information and exit.
|
|
32
|
+
|
|
33
|
+
If $ARGUMENTS is empty:
|
|
34
|
+
Tell the user: "Please provide a topic to explore. Example: /xexplore authentication"
|
|
35
|
+
Stop and wait for input.
|
|
36
|
+
|
|
37
|
+
### Step 1: Search by File Name
|
|
38
|
+
|
|
39
|
+
Find files whose names match the topic:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
find . -iname "*$ARGUMENTS*" ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/vendor/*" 2>/dev/null | head -30
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Step 2: Search by Content
|
|
46
|
+
|
|
47
|
+
Grep the codebase for the topic keyword:
|
|
48
|
+
- Search all source files for content matching $ARGUMENTS
|
|
49
|
+
- Capture file paths and line numbers for key matches
|
|
50
|
+
- Limit to first 20 matches per file to avoid flooding
|
|
51
|
+
|
|
52
|
+
### Step 3: Search Configuration
|
|
53
|
+
|
|
54
|
+
Check config files specifically:
|
|
55
|
+
- `*.json`, `*.yaml`, `*.yml`, `*.toml`, `*.env*`, `*.ini`
|
|
56
|
+
- Look for the topic in config values, keys, and comments
|
|
57
|
+
|
|
58
|
+
### Step 4: Search Tests
|
|
59
|
+
|
|
60
|
+
Find test files related to the topic:
|
|
61
|
+
- Patterns: `*test*`, `*spec*`, `__tests__/`
|
|
62
|
+
- Check both file names and file content
|
|
63
|
+
|
|
64
|
+
### Step 5: Search Documentation
|
|
65
|
+
|
|
66
|
+
Check docs for the topic:
|
|
67
|
+
- `*.md` files, `docs/` directory, `README*`
|
|
68
|
+
- Wiki or guide references
|
|
69
|
+
|
|
70
|
+
### Step 6: Report
|
|
71
|
+
|
|
72
|
+
Present findings in a structured inventory:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
## Exploration Report: [topic]
|
|
76
|
+
|
|
77
|
+
### Source Files (N found)
|
|
78
|
+
- path/to/file.ts:42 — [matching line preview]
|
|
79
|
+
|
|
80
|
+
### Tests (N found)
|
|
81
|
+
- tests/path/to/test.ts:15 — [matching line preview]
|
|
82
|
+
|
|
83
|
+
### Configuration (N found)
|
|
84
|
+
- config/settings.json:8 — [matching line preview]
|
|
85
|
+
|
|
86
|
+
### Documentation (N found)
|
|
87
|
+
- docs/guide.md:23 — [matching line preview]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If nothing is found:
|
|
91
|
+
- Tell the user: "No matches found for '[topic]'."
|
|
92
|
+
- Suggest broadening the search or trying alternate terms.
|
|
93
|
+
|
|
94
|
+
**Do NOT make any changes to any files. This command is read-only.**
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Verify references before taking action — catch fabricated URLs, placeholder IDs, and unverified claims"
|
|
3
|
+
tags: ["verification", "quality", "safety", "pre-action"]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pre-Action Verification
|
|
7
|
+
|
|
8
|
+
Scan proposed changes, generated content, or referenced artifacts for fabricated URLs, placeholder IDs, nonexistent file paths, and unverified references. Run this before committing, publishing, or acting on generated content.
|
|
9
|
+
|
|
10
|
+
## Usage Examples
|
|
11
|
+
|
|
12
|
+
**Verify current staged changes:**
|
|
13
|
+
```
|
|
14
|
+
/xverify
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Verify a specific file:**
|
|
18
|
+
```
|
|
19
|
+
/xverify README.md
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Verify generated documentation:**
|
|
23
|
+
```
|
|
24
|
+
/xverify docs/
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## What Gets Checked
|
|
28
|
+
|
|
29
|
+
### URLs and Endpoints
|
|
30
|
+
- HTTP/HTTPS URLs: attempt to confirm they are plausible (check format, known domains)
|
|
31
|
+
- API endpoints: verify they match project routes or documented APIs
|
|
32
|
+
- Flag common fabrication patterns: `example.com` placeholders, sequential IDs, lorem ipsum domains
|
|
33
|
+
|
|
34
|
+
### File Paths and References
|
|
35
|
+
- Verify referenced file paths exist on disk
|
|
36
|
+
- Check import/require statements resolve to real modules
|
|
37
|
+
- Flag references to deleted or renamed files
|
|
38
|
+
|
|
39
|
+
### IDs and Tokens
|
|
40
|
+
- Flag placeholder patterns: `xxx`, `TODO`, `FIXME`, `your-*-here`, `placeholder`
|
|
41
|
+
- Check for hardcoded test IDs that may not be valid in production
|
|
42
|
+
- Flag UUIDs or IDs that appear fabricated (all zeros, sequential)
|
|
43
|
+
|
|
44
|
+
### Claims and Assertions
|
|
45
|
+
- Cross-check version numbers against package.json or lock files
|
|
46
|
+
- Verify command names match actual available commands
|
|
47
|
+
- Check that referenced environment variables are documented
|
|
48
|
+
|
|
49
|
+
## Output Format
|
|
50
|
+
|
|
51
|
+
For each issue found, report:
|
|
52
|
+
1. **File and line** where the reference appears
|
|
53
|
+
2. **What was found** (the suspicious reference)
|
|
54
|
+
3. **Why it's suspicious** (pattern match or verification failure)
|
|
55
|
+
4. **Suggested fix** (if determinable)
|
|
56
|
+
|
|
57
|
+
## Implementation
|
|
58
|
+
|
|
59
|
+
When invoked:
|
|
60
|
+
|
|
61
|
+
1. **Determine scope**: If a file or directory argument is provided, scan that. Otherwise scan staged git changes (`git diff --cached`), or if nothing is staged, scan recent modifications.
|
|
62
|
+
|
|
63
|
+
2. **Extract references**: Parse the scoped content for:
|
|
64
|
+
- URLs (http/https links)
|
|
65
|
+
- File paths (relative and absolute)
|
|
66
|
+
- Import/require statements
|
|
67
|
+
- Version strings
|
|
68
|
+
- Environment variable references
|
|
69
|
+
- Command names with `/x` prefix
|
|
70
|
+
|
|
71
|
+
3. **Verify each reference**:
|
|
72
|
+
- File paths: check `fs.existsSync` or equivalent
|
|
73
|
+
- URLs: validate format, flag known placeholder domains
|
|
74
|
+
- Versions: cross-check against package.json
|
|
75
|
+
- Commands: cross-check against slash-commands/active/ and experiments/
|
|
76
|
+
- Env vars: check against .env.example or documentation
|
|
77
|
+
|
|
78
|
+
4. **Report findings**: Group by severity (error, warning, info) and output a summary table.
|
|
79
|
+
|
|
80
|
+
5. **Exit cleanly**: This is a read-only verification. No files are modified.
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Set up Anthropic's official devcontainer for running Claude Code with --dangerously-skip-permissions safely
|
|
3
|
+
tags: [devcontainer, security, isolation, docker, autonomous, permissions]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Set up a secure devcontainer environment based on Anthropic's official reference implementation.
|
|
7
|
+
|
|
8
|
+
Reference: https://docs.anthropic.com/en/docs/claude-code/devcontainer
|
|
9
|
+
|
|
10
|
+
First, check the current environment and any existing configuration:
|
|
11
|
+
!ls -la .devcontainer/ 2>/dev/null || echo "No existing devcontainer configuration"
|
|
12
|
+
!which docker 2>/dev/null && docker --version || echo "Docker not installed"
|
|
13
|
+
!which devcontainer 2>/dev/null && devcontainer --version || echo "devcontainer CLI not installed"
|
|
14
|
+
!echo "ANTHROPIC_API_KEY is $([ -n \"$ANTHROPIC_API_KEY\" ] && echo 'set' || echo 'NOT SET')"
|
|
15
|
+
|
|
16
|
+
Based on $ARGUMENTS, perform the appropriate devcontainer operation:
|
|
17
|
+
|
|
18
|
+
## 1. Create Devcontainer (default, --create, --setup)
|
|
19
|
+
|
|
20
|
+
If creating a new devcontainer configuration or no arguments provided:
|
|
21
|
+
|
|
22
|
+
### Recommended Security Configuration
|
|
23
|
+
|
|
24
|
+
Create `.devcontainer/devcontainer.json`:
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"name": "Claude Code Sandbox",
|
|
28
|
+
"build": {
|
|
29
|
+
"dockerfile": "Dockerfile"
|
|
30
|
+
},
|
|
31
|
+
"features": {
|
|
32
|
+
"ghcr.io/devcontainers/features/node:1": {},
|
|
33
|
+
"ghcr.io/devcontainers/features/python:1": {},
|
|
34
|
+
"ghcr.io/devcontainers/features/git:1": {},
|
|
35
|
+
"ghcr.io/devcontainers/features/github-cli:1": {},
|
|
36
|
+
"ghcr.io/devcontainers/features/aws-cli:1": {},
|
|
37
|
+
"ghcr.io/devcontainers/features/docker-in-docker:1": {}
|
|
38
|
+
},
|
|
39
|
+
"postCreateCommand": "npm install -g @anthropic-ai/claude-code && pip install --user boto3 requests",
|
|
40
|
+
"remoteEnv": {
|
|
41
|
+
"ANTHROPIC_API_KEY": "${localEnv:ANTHROPIC_API_KEY}",
|
|
42
|
+
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}",
|
|
43
|
+
"AWS_ACCESS_KEY_ID": "${localEnv:AWS_ACCESS_KEY_ID}",
|
|
44
|
+
"AWS_SECRET_ACCESS_KEY": "${localEnv:AWS_SECRET_ACCESS_KEY}",
|
|
45
|
+
"AWS_DEFAULT_REGION": "${localEnv:AWS_DEFAULT_REGION}"
|
|
46
|
+
},
|
|
47
|
+
"runArgs": [
|
|
48
|
+
"--cap-drop=ALL",
|
|
49
|
+
"--security-opt=no-new-privileges"
|
|
50
|
+
],
|
|
51
|
+
"mounts": [],
|
|
52
|
+
"customizations": {
|
|
53
|
+
"vscode": {
|
|
54
|
+
"extensions": [
|
|
55
|
+
"anthropic.claude-code"
|
|
56
|
+
],
|
|
57
|
+
"settings": {
|
|
58
|
+
"terminal.integrated.defaultProfile.linux": "bash"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Create `.devcontainer/Dockerfile`:
|
|
66
|
+
```dockerfile
|
|
67
|
+
# Anthropic's recommended devcontainer for Claude Code
|
|
68
|
+
# Reference: https://docs.anthropic.com/en/docs/claude-code/devcontainer
|
|
69
|
+
FROM mcr.microsoft.com/devcontainers/base:ubuntu
|
|
70
|
+
|
|
71
|
+
# Security labels
|
|
72
|
+
LABEL org.opencontainers.image.title="Claude Code Sandbox"
|
|
73
|
+
LABEL org.opencontainers.image.description="Secure container for running Claude Code with --dangerously-skip-permissions"
|
|
74
|
+
LABEL org.opencontainers.image.vendor="Generated by setup-devcontainer.sh"
|
|
75
|
+
|
|
76
|
+
# Install essential security tools
|
|
77
|
+
RUN apt-get update && apt-get install -y \
|
|
78
|
+
curl \
|
|
79
|
+
ca-certificates \
|
|
80
|
+
gnupg \
|
|
81
|
+
lsb-release \
|
|
82
|
+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
83
|
+
|
|
84
|
+
# Network firewall - only allow specific domains
|
|
85
|
+
RUN apt-get update && apt-get install -y iptables dnsutils && \
|
|
86
|
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
87
|
+
|
|
88
|
+
# Create firewall setup script (runs at container start)
|
|
89
|
+
# Rules are processed in order - first match wins
|
|
90
|
+
RUN echo '#!/bin/bash' > /usr/local/bin/setup-firewall.sh && \
|
|
91
|
+
echo 'set -e' >> /usr/local/bin/setup-firewall.sh && \
|
|
92
|
+
echo 'iptables -A OUTPUT -o lo -j ACCEPT' >> /usr/local/bin/setup-firewall.sh && \
|
|
93
|
+
echo 'iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT' >> /usr/local/bin/setup-firewall.sh && \
|
|
94
|
+
echo 'iptables -A OUTPUT -p udp --dport 53 -j ACCEPT' >> /usr/local/bin/setup-firewall.sh && \
|
|
95
|
+
echo 'iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT' >> /usr/local/bin/setup-firewall.sh && \
|
|
96
|
+
echo 'iptables -A OUTPUT -p tcp -d api.anthropic.com --dport 443 -j ACCEPT' >> /usr/local/bin/setup-firewall.sh && \
|
|
97
|
+
echo 'iptables -A OUTPUT -p tcp -d github.com --dport 443 -j ACCEPT' >> /usr/local/bin/setup-firewall.sh && \
|
|
98
|
+
echo 'iptables -A OUTPUT -p tcp -d registry.npmjs.org --dport 443 -j ACCEPT' >> /usr/local/bin/setup-firewall.sh && \
|
|
99
|
+
echo 'iptables -A OUTPUT -p tcp -d pypi.org --dport 443 -j ACCEPT' >> /usr/local/bin/setup-firewall.sh && \
|
|
100
|
+
echo 'iptables -A OUTPUT -p tcp -d files.pythonhosted.org --dport 443 -j ACCEPT' >> /usr/local/bin/setup-firewall.sh && \
|
|
101
|
+
echo 'iptables -A OUTPUT -p tcp --dport 443 -j DROP' >> /usr/local/bin/setup-firewall.sh && \
|
|
102
|
+
echo 'iptables -A OUTPUT -p tcp --dport 80 -j DROP' >> /usr/local/bin/setup-firewall.sh && \
|
|
103
|
+
chmod +x /usr/local/bin/setup-firewall.sh
|
|
104
|
+
|
|
105
|
+
# Create non-root user workspace
|
|
106
|
+
RUN mkdir -p /workspace && chown vscode:vscode /workspace
|
|
107
|
+
WORKDIR /workspace
|
|
108
|
+
|
|
109
|
+
# Default to non-root user
|
|
110
|
+
USER vscode
|
|
111
|
+
|
|
112
|
+
# Health check
|
|
113
|
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
114
|
+
CMD curl -sf https://api.anthropic.com/health || exit 1
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Key security features:
|
|
118
|
+
- **`--cap-drop=ALL`**: Drops all Linux capabilities
|
|
119
|
+
- **`--security-opt=no-new-privileges`**: Prevents privilege escalation
|
|
120
|
+
- **Network firewall**: Only allows traffic to allowlisted domains
|
|
121
|
+
- **No mounts**: Isolates from host filesystem
|
|
122
|
+
|
|
123
|
+
## 2. Using the Setup Script (--script)
|
|
124
|
+
|
|
125
|
+
If the user wants to use the automated setup script:
|
|
126
|
+
!ls -la setup-devcontainer.sh 2>/dev/null || echo "Script not in current directory"
|
|
127
|
+
|
|
128
|
+
Run the setup script:
|
|
129
|
+
```bash
|
|
130
|
+
# Full setup with recommended security
|
|
131
|
+
./setup-devcontainer.sh
|
|
132
|
+
|
|
133
|
+
# Minimal setup (Node.js and Git only)
|
|
134
|
+
./setup-devcontainer.sh --minimal
|
|
135
|
+
|
|
136
|
+
# Skip network firewall restrictions
|
|
137
|
+
./setup-devcontainer.sh --no-network-firewall
|
|
138
|
+
|
|
139
|
+
# Preview what would be created
|
|
140
|
+
./setup-devcontainer.sh --dry-run
|
|
141
|
+
|
|
142
|
+
# Strict mode for CI (fails if prerequisites missing)
|
|
143
|
+
./setup-devcontainer.sh --strict
|
|
144
|
+
|
|
145
|
+
# Add custom domains for enterprise private registries
|
|
146
|
+
./setup-devcontainer.sh --allow-domain internal.registry.com
|
|
147
|
+
|
|
148
|
+
# Or use environment variable for extra domains
|
|
149
|
+
DEVCONTAINER_EXTRA_DOMAINS="internal.registry.com,npm.mycompany.com" ./setup-devcontainer.sh
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 3. Start Container (--start, --up)
|
|
153
|
+
|
|
154
|
+
If starting the devcontainer:
|
|
155
|
+
!docker ps -a | grep -i devcontainer | head -3 || echo "No devcontainer running"
|
|
156
|
+
|
|
157
|
+
Start commands:
|
|
158
|
+
```bash
|
|
159
|
+
# Using VS Code
|
|
160
|
+
# Cmd/Ctrl+Shift+P → "Dev Containers: Reopen in Container"
|
|
161
|
+
|
|
162
|
+
# Using devcontainer CLI
|
|
163
|
+
devcontainer up --workspace-folder .
|
|
164
|
+
devcontainer exec --workspace-folder . claude --dangerously-skip-permissions
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 4. Security Validation (--validate, --check)
|
|
168
|
+
|
|
169
|
+
If validating the devcontainer security:
|
|
170
|
+
!cat .devcontainer/devcontainer.json 2>/dev/null | grep -E "(cap-drop|no-new-privileges|mounts)" || echo "Security settings not found"
|
|
171
|
+
!cat .devcontainer/Dockerfile 2>/dev/null | grep -E "(iptables|DROP)" || echo "Firewall rules not found"
|
|
172
|
+
|
|
173
|
+
Verify:
|
|
174
|
+
- [ ] `--cap-drop=ALL` is present in runArgs
|
|
175
|
+
- [ ] `--security-opt=no-new-privileges` is present
|
|
176
|
+
- [ ] Network firewall rules block unauthorized outbound traffic
|
|
177
|
+
- [ ] No host filesystem mounts configured
|
|
178
|
+
|
|
179
|
+
## 5. Cleanup (--cleanup, --remove)
|
|
180
|
+
|
|
181
|
+
If cleaning up devcontainer:
|
|
182
|
+
```bash
|
|
183
|
+
# Stop and remove container
|
|
184
|
+
devcontainer down --workspace-folder .
|
|
185
|
+
|
|
186
|
+
# Remove configuration (optional)
|
|
187
|
+
rm -rf .devcontainer/
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Comparison: /sandbox vs Devcontainer
|
|
191
|
+
|
|
192
|
+
| Aspect | Claude's `/sandbox` | Devcontainer |
|
|
193
|
+
|--------|---------------------|--------------|
|
|
194
|
+
| **Purpose** | Run code snippets safely | Run Claude itself isolated |
|
|
195
|
+
| **Scope** | Ephemeral execution | Persistent dev environment |
|
|
196
|
+
| **What's isolated** | Your code | The entire Claude session |
|
|
197
|
+
| **Use case** | "Test this script" | "Let Claude work autonomously" |
|
|
198
|
+
| **Flag enabled** | N/A | `--dangerously-skip-permissions` |
|
|
199
|
+
|
|
200
|
+
## Security Considerations
|
|
201
|
+
|
|
202
|
+
**Safe for:**
|
|
203
|
+
- Your own trusted projects
|
|
204
|
+
- Development and testing workflows
|
|
205
|
+
- CI/CD automation with Claude
|
|
206
|
+
|
|
207
|
+
**Avoid for:**
|
|
208
|
+
- Untrusted repositories (prompt injection risk)
|
|
209
|
+
- Projects with sensitive credentials you haven't reviewed
|
|
210
|
+
- Production systems
|
|
211
|
+
|
|
212
|
+
**Remember:** Even with isolation, credentials inside the container are accessible to Claude. Only pass credentials you're comfortable with Claude having access to.
|
|
213
|
+
|
|
214
|
+
## Quick Start
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# 1. Set API key
|
|
218
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
219
|
+
|
|
220
|
+
# 2. Run setup script (or create files manually)
|
|
221
|
+
./setup-devcontainer.sh
|
|
222
|
+
|
|
223
|
+
# 3. Open in VS Code and reopen in container
|
|
224
|
+
code . && # Cmd+Shift+P → "Dev Containers: Reopen in Container"
|
|
225
|
+
|
|
226
|
+
# 4. Run Claude with full autonomy
|
|
227
|
+
claude --dangerously-skip-permissions
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Think step by step about the user's devcontainer needs and provide:
|
|
231
|
+
|
|
232
|
+
1. **Environment Assessment**: Current setup, Docker availability, existing configuration
|
|
233
|
+
2. **Security Recommendation**: Appropriate isolation level based on use case
|
|
234
|
+
3. **Implementation**: Create or modify devcontainer configuration
|
|
235
|
+
4. **Validation**: Verify security settings are correctly applied
|
|
236
|
+
5. **Usage Instructions**: How to start and use the devcontainer
|
|
237
|
+
|
|
238
|
+
If no specific operation is provided, assess the current environment and help create a secure devcontainer configuration using Anthropic's recommended approach.
|