codeforge-dev 1.11.0 → 1.12.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 (56) hide show
  1. package/.devcontainer/.env +7 -1
  2. package/.devcontainer/.gitignore +1 -0
  3. package/.devcontainer/CHANGELOG.md +69 -0
  4. package/.devcontainer/CLAUDE.md +73 -3
  5. package/.devcontainer/README.md +33 -7
  6. package/.devcontainer/config/defaults/main-system-prompt.md +28 -0
  7. package/.devcontainer/config/defaults/writing-system-prompt.md +46 -4
  8. package/.devcontainer/connect-external-terminal.ps1 +1 -1
  9. package/.devcontainer/devcontainer.json +32 -9
  10. package/.devcontainer/docs/configuration-reference.md +3 -0
  11. package/.devcontainer/docs/plugins.md +9 -2
  12. package/.devcontainer/docs/troubleshooting.md +2 -2
  13. package/.devcontainer/features/README.md +8 -9
  14. package/.devcontainer/features/agent-browser/devcontainer-feature.json +21 -21
  15. package/.devcontainer/features/agent-browser/install.sh +0 -7
  16. package/.devcontainer/features/ast-grep/devcontainer-feature.json +22 -22
  17. package/.devcontainer/features/biome/devcontainer-feature.json +12 -14
  18. package/.devcontainer/features/ccms/install.sh +30 -13
  19. package/.devcontainer/features/lsp-servers/devcontainer-feature.json +43 -43
  20. package/.devcontainer/features/mcp-qdrant/poststart-hook.sh +2 -1
  21. package/.devcontainer/features/ruff/devcontainer-feature.json +17 -19
  22. package/.devcontainer/features/tmux/install.sh +2 -2
  23. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/README.md +81 -0
  24. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/README.md +92 -0
  25. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/README.md +250 -0
  26. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/claude-guide.md +1 -1
  27. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/debug-logs.md +1 -1
  28. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/dependency-analyst.md +1 -1
  29. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/explorer.md +1 -1
  30. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/generalist.md +1 -1
  31. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/git-archaeologist.md +2 -2
  32. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/researcher.md +1 -1
  33. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/security-auditor.md +1 -1
  34. package/.devcontainer/plugins/devs-marketplace/plugins/codeforge-lsp/README.md +41 -0
  35. package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/README.md +72 -0
  36. package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/scripts/block-dangerous.py +73 -47
  37. package/.devcontainer/plugins/devs-marketplace/plugins/notify-hook/README.md +42 -0
  38. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/README.md +86 -0
  39. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/hooks/hooks.json +25 -15
  40. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/guard-protected-bash.py +122 -0
  41. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/guard-protected.py +3 -3
  42. package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/README.md +96 -0
  43. package/.devcontainer/plugins/devs-marketplace/plugins/workspace-scope-guard/README.md +94 -0
  44. package/.devcontainer/plugins/devs-marketplace/plugins/workspace-scope-guard/scripts/guard-workspace-scope.py +1 -1
  45. package/.devcontainer/scripts/check-setup.sh +1 -1
  46. package/.devcontainer/scripts/setup-projects.sh +23 -16
  47. package/.devcontainer/scripts/setup.sh +48 -5
  48. package/README.md +17 -8
  49. package/package.json +1 -2
  50. package/.devcontainer/features/mcp-reasoner/README.md +0 -177
  51. package/.devcontainer/features/mcp-reasoner/devcontainer-feature.json +0 -25
  52. package/.devcontainer/features/mcp-reasoner/install.sh +0 -184
  53. package/.devcontainer/features/mcp-reasoner/poststart-hook.sh +0 -67
  54. package/.devcontainer/features/splitrail/README.md +0 -140
  55. package/.devcontainer/features/splitrail/devcontainer-feature.json +0 -39
  56. package/.devcontainer/features/splitrail/install.sh +0 -136
@@ -0,0 +1,250 @@
1
+ # code-directive
2
+
3
+ The core Claude Code plugin for CodeForge. Provides 17 custom agent definitions, 28 coding reference skills, and 12 hook scripts spanning 6 lifecycle events. Handles agent redirection, skill suggestion, syntax validation, edited file collection, advisory testing, and session-start context injection.
4
+
5
+ ## What It Does
6
+
7
+ ### Agents (17)
8
+
9
+ Custom agent definitions that replace Claude Code's built-in subagents with enhanced, purpose-built alternatives. Each agent is a markdown prompt file in `agents/` that defines the agent's role, constraints, tools, and workflow.
10
+
11
+ | Agent | Role |
12
+ |-------|------|
13
+ | `architect` | System design, planning, architecture decisions |
14
+ | `bash-exec` | Shell command execution with safety guardrails |
15
+ | `claude-guide` | Claude Code usage guidance and troubleshooting |
16
+ | `debug-logs` | Log analysis and debugging |
17
+ | `dependency-analyst` | Dependency auditing, upgrades, and vulnerability analysis |
18
+ | `doc-writer` | Documentation authoring |
19
+ | `explorer` | Codebase exploration and context gathering |
20
+ | `generalist` | General-purpose tasks |
21
+ | `git-archaeologist` | Git history investigation and forensics |
22
+ | `migrator` | Code migration and framework upgrades |
23
+ | `perf-profiler` | Performance profiling and optimization |
24
+ | `refactorer` | Code refactoring and restructuring |
25
+ | `researcher` | Research and information gathering |
26
+ | `security-auditor` | Security review and vulnerability assessment |
27
+ | `spec-writer` | Specification authoring |
28
+ | `statusline-config` | Status line configuration |
29
+ | `test-writer` | Test authoring |
30
+
31
+ ### Agent Redirection
32
+
33
+ The `redirect-builtin-agents.py` PreToolUse hook transparently swaps built-in agent types to custom agents whenever Claude spawns a subagent via the Task tool:
34
+
35
+ | Built-in Agent | Redirects To |
36
+ |----------------|--------------|
37
+ | `Explore` | `explorer` |
38
+ | `Plan` | `architect` |
39
+ | `general-purpose` | `generalist` |
40
+ | `Bash` | `bash-exec` |
41
+ | `claude-code-guide` | `claude-guide` |
42
+ | `statusline-setup` | `statusline-config` |
43
+
44
+ See `AGENT-REDIRECTION.md` for the full technical guide on how the PreToolUse hook contract works.
45
+
46
+ ### Skills (28)
47
+
48
+ Reference skill packages that provide domain-specific knowledge. Each skill lives in its own directory under `skills/` with a `SKILL.md` entry point and optional `references/` subdirectory. Skills are loaded on demand via slash commands.
49
+
50
+ | Skill | Domain |
51
+ |-------|--------|
52
+ | `api-design` | REST conventions, error handling |
53
+ | `ast-grep-patterns` | Structural code search patterns |
54
+ | `claude-agent-sdk` | Claude Agent SDK (TypeScript) |
55
+ | `claude-code-headless` | Claude Code CLI, SDK, and MCP |
56
+ | `debugging` | Error patterns, log analysis |
57
+ | `dependency-management` | Package ecosystems, license compliance |
58
+ | `docker` | Dockerfile patterns, Compose services |
59
+ | `docker-py` | Docker SDK for Python |
60
+ | `documentation-patterns` | API docs, docstring formats |
61
+ | `fastapi` | FastAPI routing, Pydantic, SSE, middleware |
62
+ | `git-forensics` | Git investigation commands, playbooks |
63
+ | `migration-patterns` | Python and JavaScript migration guides |
64
+ | `performance-profiling` | Profiling tools, result interpretation |
65
+ | `pydantic-ai` | PydanticAI agents, tools, models |
66
+ | `refactoring-patterns` | Safe transformations, code smell catalog |
67
+ | `security-checklist` | OWASP patterns, secrets management |
68
+ | `skill-building` | Skill authoring patterns and principles |
69
+ | `spec-build` | Specification-driven implementation lifecycle |
70
+ | `spec-check` | Specification health audit |
71
+ | `spec-init` | Initialize `.specs/` directory |
72
+ | `spec-new` | Create new specification from template |
73
+ | `spec-refine` | Validate spec assumptions with user |
74
+ | `spec-review` | Verify implementation against spec |
75
+ | `spec-update` | As-built spec update |
76
+ | `specification-writing` | EARS templates, criteria patterns |
77
+ | `sqlite` | SQLite patterns (Python, JavaScript, advanced) |
78
+ | `svelte5` | Svelte 5 runes, components, routing |
79
+ | `testing` | FastAPI testing, Svelte testing |
80
+
81
+ ### Hook Scripts (12)
82
+
83
+ | Script | Hook Event | Matcher | Purpose |
84
+ |--------|-----------|---------|---------|
85
+ | `redirect-builtin-agents.py` | PreToolUse | Task | Redirects built-in agents to custom agents |
86
+ | `skill-suggester.py` | UserPromptSubmit | * | Suggests relevant skills based on prompt keywords |
87
+ | `ticket-linker.py` | UserPromptSubmit | * | Auto-fetches GitHub issues/PRs referenced by #123 or URL |
88
+ | `skill-suggester.py` | SubagentStart | Plan | Suggests skills for planning agents |
89
+ | `inject-cwd.py` | SubagentStart | * | Injects working directory into subagent context |
90
+ | `advisory-test-runner.py` | Stop | * | Runs affected tests and injects results as context |
91
+ | `commit-reminder.py` | Stop | * | Advises about uncommitted changes |
92
+ | `spec-reminder.py` | Stop | * | Advises about spec updates after code changes |
93
+ | `git-state-injector.py` | SessionStart | * | Injects branch, status, and recent commits at session start |
94
+ | `todo-harvester.py` | SessionStart | * | Surfaces TODO/FIXME/HACK/XXX comments from the codebase |
95
+ | `syntax-validator.py` | PostToolUse | Edit\|Write | Validates JSON, JSONC, YAML, TOML syntax after edits |
96
+ | `collect-edited-files.py` | PostToolUse | Edit\|Write | Records edited file paths for batch formatting/linting |
97
+
98
+ ## How It Works
99
+
100
+ ### Hook Lifecycle
101
+
102
+ ```
103
+ Session starts
104
+
105
+ ├─→ git-state-injector.py Injects branch, status, recent commits
106
+ └─→ todo-harvester.py Surfaces TODO/FIXME markers
107
+
108
+ User submits a prompt
109
+
110
+ ├─→ skill-suggester.py Suggests skills matching prompt keywords
111
+ └─→ ticket-linker.py Fetches GitHub issues referenced by #123 or URL
112
+
113
+ Claude spawns a subagent
114
+
115
+ ├─→ redirect-builtin-agents.py Swaps built-in agents for custom ones (Task matcher)
116
+ ├─→ skill-suggester.py Suggests skills for Plan agents
117
+ └─→ inject-cwd.py Tells subagent the working directory
118
+
119
+ Claude edits a file (Edit/Write)
120
+
121
+ ├─→ syntax-validator.py Validates JSON/YAML/TOML syntax immediately
122
+ └─→ collect-edited-files.py Appends path to session temp files
123
+
124
+ Claude stops responding
125
+
126
+ ├─→ advisory-test-runner.py Runs affected tests, injects results
127
+ ├─→ commit-reminder.py Advises about uncommitted changes
128
+ └─→ spec-reminder.py Advises about spec updates
129
+ ```
130
+
131
+ ### Temp File Convention
132
+
133
+ Edited file paths are stored in session-scoped temp files for downstream consumption:
134
+ - `/tmp/claude-edited-files-{session_id}` — consumed by the `auto-formatter` plugin
135
+ - `/tmp/claude-lint-files-{session_id}` — consumed by the `auto-linter` plugin
136
+
137
+ ### Advisory Test Runner
138
+
139
+ The test runner maps edited source files to their corresponding test files, runs only affected tests, and injects pass/fail results as `additionalContext`. It never blocks Claude — results are purely informational.
140
+
141
+ ### Skill Suggester
142
+
143
+ Matches user prompts against keyword maps (phrases + individual terms) for each skill. When a skill matches, it injects a suggestion as `systemMessage` (UserPromptSubmit) or `additionalContext` (SubagentStart) so Claude knows which skill to load.
144
+
145
+ ### Ticket Linker
146
+
147
+ Detects `#123` references and full GitHub issue/PR URLs in user prompts, fetches the ticket body via `gh`, and injects it as `additionalContext`. Handles up to 3 references per prompt with a 1500-character cap per ticket body.
148
+
149
+ ### Timeouts
150
+
151
+ | Script | Timeout |
152
+ |--------|---------|
153
+ | redirect-builtin-agents.py | 5s |
154
+ | skill-suggester.py | 3s |
155
+ | ticket-linker.py | 12s |
156
+ | inject-cwd.py | 3s |
157
+ | advisory-test-runner.py | 20s |
158
+ | commit-reminder.py | 8s |
159
+ | spec-reminder.py | 8s |
160
+ | git-state-injector.py | 10s |
161
+ | todo-harvester.py | 8s |
162
+ | syntax-validator.py | 5s |
163
+ | collect-edited-files.py | 3s |
164
+
165
+ ## Documentation
166
+
167
+ - `AGENT-REDIRECTION.md` — Technical guide to the PreToolUse hook contract for agent redirection
168
+ - `REVIEW-RUBRIC.md` — Quality rubric for agent and skill design, based on Anthropic's prompt engineering documentation
169
+
170
+ ## Plugin Structure
171
+
172
+ ```
173
+ code-directive/
174
+ ├── .claude-plugin/
175
+ │ ├── plugin.json # Plugin metadata
176
+ │ └── commands/
177
+ │ └── debug.md # /debug slash command
178
+ ├── agents/ # 17 custom agent definitions
179
+ │ ├── architect.md
180
+ │ ├── bash-exec.md
181
+ │ ├── claude-guide.md
182
+ │ ├── debug-logs.md
183
+ │ ├── dependency-analyst.md
184
+ │ ├── doc-writer.md
185
+ │ ├── explorer.md
186
+ │ ├── generalist.md
187
+ │ ├── git-archaeologist.md
188
+ │ ├── migrator.md
189
+ │ ├── perf-profiler.md
190
+ │ ├── refactorer.md
191
+ │ ├── researcher.md
192
+ │ ├── security-auditor.md
193
+ │ ├── spec-writer.md
194
+ │ ├── statusline-config.md
195
+ │ └── test-writer.md
196
+ ├── skills/ # 28 coding reference skills
197
+ │ ├── api-design/
198
+ │ ├── ast-grep-patterns/
199
+ │ ├── claude-agent-sdk/
200
+ │ ├── claude-code-headless/
201
+ │ ├── debugging/
202
+ │ ├── dependency-management/
203
+ │ ├── docker/
204
+ │ ├── docker-py/
205
+ │ ├── documentation-patterns/
206
+ │ ├── fastapi/
207
+ │ ├── git-forensics/
208
+ │ ├── migration-patterns/
209
+ │ ├── performance-profiling/
210
+ │ ├── pydantic-ai/
211
+ │ ├── refactoring-patterns/
212
+ │ ├── security-checklist/
213
+ │ ├── skill-building/
214
+ │ ├── spec-build/
215
+ │ ├── spec-check/
216
+ │ ├── spec-init/
217
+ │ ├── spec-new/
218
+ │ ├── spec-refine/
219
+ │ ├── spec-review/
220
+ │ ├── spec-update/
221
+ │ ├── specification-writing/
222
+ │ ├── sqlite/
223
+ │ ├── svelte5/
224
+ │ └── testing/
225
+ ├── hooks/
226
+ │ └── hooks.json # All hook registrations (6 events, 12 scripts)
227
+ ├── scripts/
228
+ │ ├── advisory-test-runner.py # Stop: runs affected tests
229
+ │ ├── collect-edited-files.py # PostToolUse: records edited file paths
230
+ │ ├── commit-reminder.py # Stop: uncommitted changes advisory
231
+ │ ├── git-state-injector.py # SessionStart: injects git state
232
+ │ ├── guard-readonly-bash.py # Read-only bash guard (used by agents)
233
+ │ ├── inject-cwd.py # SubagentStart: injects working directory
234
+ │ ├── redirect-builtin-agents.py # PreToolUse: agent redirection
235
+ │ ├── skill-suggester.py # UserPromptSubmit/SubagentStart: skill suggestions
236
+ │ ├── spec-reminder.py # Stop: spec update advisory
237
+ │ ├── syntax-validator.py # PostToolUse: JSON/YAML/TOML validation
238
+ │ ├── ticket-linker.py # UserPromptSubmit: auto-fetch GitHub issues
239
+ │ ├── todo-harvester.py # SessionStart: TODO/FIXME surfacing
240
+ │ ├── verify-no-regression.py # Test verification utility
241
+ │ └── verify-tests-pass.py # Test verification utility
242
+ ├── AGENT-REDIRECTION.md # Agent redirection technical guide
243
+ └── REVIEW-RUBRIC.md # Agent & skill quality rubric
244
+ ```
245
+
246
+ ## Requirements
247
+
248
+ - Python 3.11+
249
+ - Claude Code with plugin hook support
250
+ - [GitHub CLI](https://cli.github.com/) (`gh`) for ticket-linker functionality
@@ -11,7 +11,7 @@ description: >-
11
11
  spawning a new instance, check if there is already a running or recently
12
12
  completed claude-guide agent that you can resume using the "resume" parameter.
13
13
  tools: Glob, Grep, Read, WebFetch, WebSearch
14
- model: haiku
14
+ model: sonnet
15
15
  color: cyan
16
16
  memory:
17
17
  scope: user
@@ -5,7 +5,7 @@ description: >-
5
5
  application frameworks, and system services to identify errors, crashes,
6
6
  and performance issues. Reports structured findings with root cause assessment.
7
7
  tools: Bash, Read, Glob, Grep
8
- model: sonnet
8
+ model: opus
9
9
  color: red
10
10
  skills:
11
11
  - debugging
@@ -10,7 +10,7 @@ description: >-
10
10
  dependency analysis across Node.js, Python, Rust, or Go ecosystems.
11
11
  Reports findings without modifying any files.
12
12
  tools: Read, Bash, Glob, Grep
13
- model: haiku
13
+ model: sonnet
14
14
  color: blue
15
15
  memory:
16
16
  scope: project
@@ -10,7 +10,7 @@ description: >-
10
10
  very thorough. Reports findings with absolute file paths and never
11
11
  modifies any files.
12
12
  tools: Read, Glob, Grep, Bash
13
- model: haiku
13
+ model: sonnet
14
14
  color: blue
15
15
  memory:
16
16
  scope: project
@@ -8,7 +8,7 @@ description: >-
8
8
  any complex task that doesn't fit a specialist agent's domain. Has access
9
9
  to all tools and can both read and write files.
10
10
  tools: "*"
11
- model: inherit
11
+ model: opus
12
12
  color: green
13
13
  memory:
14
14
  scope: project
@@ -9,7 +9,7 @@ description: >-
9
9
  of this file", "who contributed to this module", "recover lost commit",
10
10
  "trace this function's evolution", or needs any git history forensics.
11
11
  tools: Read, Grep, Bash
12
- model: haiku
12
+ model: sonnet
13
13
  color: blue
14
14
  memory:
15
15
  scope: project
@@ -52,7 +52,7 @@ Before starting work, read project-specific instructions:
52
52
  - **NEVER** change the working tree — no `git checkout`, `git reset`, `git restore`, `git clean`, or `git switch`. Changing the working tree could discard the user's uncommitted work.
53
53
  - **NEVER** modify refs — no `git tag`, `git branch -d`, `git branch -m`, or `git update-ref`.
54
54
  - **NEVER** modify configuration — no `git config` writes.
55
- - Your Bash usage is **git-read-only guarded**. Only these git subcommands are permitted: `log`, `blame`, `show`, `diff`, `bisect` (view mode only), `reflog`, `shortlog`, `rev-list`, `rev-parse`, `ls-files`, `ls-tree`, `cat-file`, `name-rev`, `describe`, `merge-base`, `branch -a` / `branch --list`, `remote -v`, `stash list`.
55
+ - Your Bash usage is **git-read-only guarded**. Only these git subcommands are permitted: `log`, `blame`, `show`, `diff`, `bisect` (view mode only), `reflog`, `shortlog`, `rev-list`, `rev-parse`, `ls-files`, `ls-tree`, `cat-file`, `name-rev`, `describe`, `merge-base`, `branch -a` / `branch --list`, `remote -v`, `stash list`, `worktree list`.
56
56
  - You may also use `Read`, `Grep`, and non-git Bash commands that are read-only (`wc`, `sort`, `head`, `uniq`).
57
57
 
58
58
  ## Investigation Workflow
@@ -9,7 +9,7 @@ description: >-
9
9
  technology comparison, or technical deep-dives. Reports structured findings
10
10
  with citations without modifying any files.
11
11
  tools: Read, Glob, Grep, WebSearch, WebFetch, Bash
12
- model: sonnet
12
+ model: opus
13
13
  color: cyan
14
14
  memory:
15
15
  scope: user
@@ -10,7 +10,7 @@ description: >-
10
10
  Reports findings with severity ratings and remediation guidance without
11
11
  modifying any files.
12
12
  tools: Read, Glob, Grep, Bash
13
- model: sonnet
13
+ model: opus
14
14
  color: red
15
15
  memory:
16
16
  scope: user
@@ -0,0 +1,41 @@
1
+ # codeforge-lsp
2
+
3
+ Purely declarative Claude Code plugin that registers Language Server Protocol (LSP) servers for Python, TypeScript/JavaScript, and Go. No hooks, no scripts — just server definitions in the plugin manifest.
4
+
5
+ ## What It Does
6
+
7
+ Provides Claude Code with language intelligence (type checking, diagnostics, go-to-definition) by registering three LSP servers:
8
+
9
+ | Server | Command | Languages | File Extensions |
10
+ |--------|---------|-----------|-----------------|
11
+ | [Pyright](https://github.com/microsoft/pyright) | `pyright-langserver --stdio` | Python | `.py`, `.pyi` |
12
+ | [TypeScript Language Server](https://github.com/typescript-language-server/typescript-language-server) | `typescript-language-server --stdio` | TypeScript, JavaScript | `.ts`, `.tsx`, `.js`, `.jsx`, `.mts`, `.cts`, `.mjs`, `.cjs` |
13
+ | [gopls](https://pkg.go.dev/golang.org/x/tools/gopls) | `gopls serve` | Go | `.go`, `.mod`, `.sum` |
14
+
15
+ Servers activate only if their binary is available on PATH. Missing servers are silently skipped — the plugin never fails on a missing tool.
16
+
17
+ ## How It Works
18
+
19
+ The plugin uses the `lspServers` field in `plugin.json` to declare server configurations. Claude Code reads this at startup and launches each server whose command binary exists. There is no hook logic or runtime behavior — everything is static configuration.
20
+
21
+ Each server maps file extensions to language identifiers. When Claude Code opens a file matching a registered extension, it routes it to the corresponding LSP server for diagnostics, completions, and other language features.
22
+
23
+ ## Plugin Structure
24
+
25
+ ```
26
+ codeforge-lsp/
27
+ ├── .claude-plugin/
28
+ │ └── plugin.json # Plugin metadata + LSP server definitions
29
+ └── README.md # This file
30
+ ```
31
+
32
+ ## Requirements
33
+
34
+ - Claude Code with LSP plugin support
35
+ - Install the language servers you need:
36
+
37
+ | Server | Install |
38
+ |--------|---------|
39
+ | Pyright | `npm i -g pyright` |
40
+ | TypeScript Language Server | `npm i -g typescript-language-server typescript` |
41
+ | gopls | `go install golang.org/x/tools/gopls@latest` |
@@ -0,0 +1,72 @@
1
+ # dangerous-command-blocker
2
+
3
+ Claude Code plugin that intercepts Bash tool calls and blocks destructive commands before they execute. Acts as a safety net against accidental or misguided destructive operations.
4
+
5
+ ## What It Does
6
+
7
+ Inspects every Bash command Claude attempts to run against a set of dangerous patterns. If a match is found, the command is blocked with an error message explaining why. Safe commands pass through untouched.
8
+
9
+ ### Blocked Patterns
10
+
11
+ | Category | Examples |
12
+ |----------|----------|
13
+ | Destructive filesystem deletion | `rm -rf /`, `rm -rf ~`, `rm -rf ../` |
14
+ | Privileged deletion | `sudo rm` |
15
+ | World-writable permissions | `chmod 777`, `chmod -R 777` |
16
+ | Force push to main/master | `git push --force origin main`, `git push -f origin master` |
17
+ | Bare force push | `git push -f`, `git push --force` (no branch specified) |
18
+ | Git history destruction | `git reset --hard origin/main`, `git clean -f` |
19
+ | System directory writes | `> /usr/`, `> /etc/`, `> /bin/`, `> /sbin/` |
20
+ | Disk formatting | `mkfs.*`, `dd of=/dev/` |
21
+ | Docker container escape | `docker run --privileged`, `docker run -v /:/...` |
22
+ | Destructive Docker operations | `docker stop`, `docker rm`, `docker kill`, `docker rmi` |
23
+ | Dangerous find operations | `find -exec rm`, `find -delete` |
24
+
25
+ ## How It Works
26
+
27
+ ### Hook Lifecycle
28
+
29
+ ```
30
+ Claude calls the Bash tool
31
+
32
+ └─→ PreToolUse hook fires for Bash
33
+
34
+ └─→ block-dangerous.py reads the command from stdin
35
+
36
+ ├─→ Pattern match found → exit 2 (block with error)
37
+ └─→ No match → exit 0 (allow)
38
+ ```
39
+
40
+ ### Exit Code Behavior
41
+
42
+ | Exit Code | Meaning |
43
+ |-----------|---------|
44
+ | 0 | Command is safe — allow execution |
45
+ | 2 | Command matches a dangerous pattern — block with error message |
46
+
47
+ ### Error Handling
48
+
49
+ - **JSON parse failure**: Fails closed (exit 2) — if the input can't be read, the command is blocked
50
+ - **Other exceptions**: Fails open (exit 0) — logs the error to stderr but does not block
51
+
52
+ ### Timeout
53
+
54
+ The hook has a 5-second timeout. If the script takes longer, Claude Code proceeds with the command.
55
+
56
+ ## Plugin Structure
57
+
58
+ ```
59
+ dangerous-command-blocker/
60
+ ├── .claude-plugin/
61
+ │ └── plugin.json # Plugin metadata
62
+ ├── hooks/
63
+ │ └── hooks.json # PreToolUse/Bash hook registration
64
+ ├── scripts/
65
+ │ └── block-dangerous.py # Pattern matcher (PreToolUse)
66
+ └── README.md # This file
67
+ ```
68
+
69
+ ## Requirements
70
+
71
+ - Python 3.11+
72
+ - Claude Code with plugin hook support
@@ -13,54 +13,82 @@ import sys
13
13
 
14
14
  DANGEROUS_PATTERNS = [
15
15
  # Destructive filesystem deletion
16
- (r'\brm\s+.*-[^\s]*r[^\s]*f[^\s]*\s+[/~](?:\s|$)',
17
- "Blocked: rm -rf on root or home directory"),
18
- (r'\brm\s+.*-[^\s]*f[^\s]*r[^\s]*\s+[/~](?:\s|$)',
19
- "Blocked: rm -rf on root or home directory"),
20
- (r'\brm\s+-rf\s+/(?:\s|$)',
21
- "Blocked: rm -rf /"),
22
- (r'\brm\s+-rf\s+~(?:\s|$)',
23
- "Blocked: rm -rf ~"),
24
-
16
+ (
17
+ r"\brm\s+.*-[^\s]*r[^\s]*f[^\s]*\s+[/~](?:\s|$)",
18
+ "Blocked: rm -rf on root or home directory",
19
+ ),
20
+ (
21
+ r"\brm\s+.*-[^\s]*f[^\s]*r[^\s]*\s+[/~](?:\s|$)",
22
+ "Blocked: rm -rf on root or home directory",
23
+ ),
24
+ (r"\brm\s+-rf\s+/(?:\s|$)", "Blocked: rm -rf /"),
25
+ (r"\brm\s+-rf\s+~(?:\s|$)", "Blocked: rm -rf ~"),
25
26
  # Root-level file removal
26
- (r'\bsudo\s+rm\b',
27
- "Blocked: sudo rm - use caution with privileged deletion"),
28
-
27
+ (r"\bsudo\s+rm\b", "Blocked: sudo rm - use caution with privileged deletion"),
29
28
  # World-writable permissions
30
- (r'\bchmod\s+777\b',
31
- "Blocked: chmod 777 creates security vulnerability"),
32
- (r'\bchmod\s+-R\s+777\b',
33
- "Blocked: recursive chmod 777 creates security vulnerability"),
34
-
29
+ (r"\bchmod\s+777\b", "Blocked: chmod 777 creates security vulnerability"),
30
+ (
31
+ r"\bchmod\s+-R\s+777\b",
32
+ "Blocked: recursive chmod 777 creates security vulnerability",
33
+ ),
35
34
  # Force push to main/master
36
- (r'\bgit\s+push\s+.*--force.*\s+(origin\s+)?(main|master)\b',
37
- "Blocked: force push to main/master destroys history"),
38
- (r'\bgit\s+push\s+.*-f\s+.*\s+(origin\s+)?(main|master)\b',
39
- "Blocked: force push to main/master destroys history"),
40
- (r'\bgit\s+push\s+-f\s+(origin\s+)?(main|master)\b',
41
- "Blocked: force push to main/master destroys history"),
42
- (r'\bgit\s+push\s+--force\s+(origin\s+)?(main|master)\b',
43
- "Blocked: force push to main/master destroys history"),
44
-
35
+ (
36
+ r"\bgit\s+push\s+.*--force.*\s+(origin\s+)?(main|master)\b",
37
+ "Blocked: force push to main/master destroys history",
38
+ ),
39
+ (
40
+ r"\bgit\s+push\s+.*-f\s+.*\s+(origin\s+)?(main|master)\b",
41
+ "Blocked: force push to main/master destroys history",
42
+ ),
43
+ (
44
+ r"\bgit\s+push\s+-f\s+(origin\s+)?(main|master)\b",
45
+ "Blocked: force push to main/master destroys history",
46
+ ),
47
+ (
48
+ r"\bgit\s+push\s+--force\s+(origin\s+)?(main|master)\b",
49
+ "Blocked: force push to main/master destroys history",
50
+ ),
45
51
  # System directory modification
46
- (r'>\s*/usr/',
47
- "Blocked: writing to /usr system directory"),
48
- (r'>\s*/etc/',
49
- "Blocked: writing to /etc system directory"),
50
- (r'>\s*/bin/',
51
- "Blocked: writing to /bin system directory"),
52
- (r'>\s*/sbin/',
53
- "Blocked: writing to /sbin system directory"),
54
-
52
+ (r">\s*/usr/", "Blocked: writing to /usr system directory"),
53
+ (r">\s*/etc/", "Blocked: writing to /etc system directory"),
54
+ (r">\s*/bin/", "Blocked: writing to /bin system directory"),
55
+ (r">\s*/sbin/", "Blocked: writing to /sbin system directory"),
55
56
  # Disk formatting
56
- (r'\bmkfs\.\w+',
57
- "Blocked: disk formatting command"),
58
- (r'\bdd\s+.*of=/dev/',
59
- "Blocked: dd writing to device"),
60
-
57
+ (r"\bmkfs\.\w+", "Blocked: disk formatting command"),
58
+ (r"\bdd\s+.*of=/dev/", "Blocked: dd writing to device"),
61
59
  # History manipulation
62
- (r'\bgit\s+reset\s+--hard\s+origin/(main|master)\b',
63
- "Blocked: hard reset to remote main/master - destructive operation"),
60
+ (
61
+ r"\bgit\s+reset\s+--hard\s+origin/(main|master)\b",
62
+ "Blocked: hard reset to remote main/master - destructive operation",
63
+ ),
64
+ # Docker container escape
65
+ (
66
+ r"\bdocker\s+run\s+.*--privileged",
67
+ "Blocked: docker run --privileged allows container escape",
68
+ ),
69
+ (
70
+ r"\bdocker\s+run\s+.*-v\s+/:/\w",
71
+ "Blocked: docker run mounting host root filesystem",
72
+ ),
73
+ # Destructive Docker operations
74
+ (
75
+ r"\bdocker\s+(stop|rm|kill|rmi)\s+",
76
+ "Blocked: destructive docker operation - use with caution",
77
+ ),
78
+ # Additional rm patterns
79
+ (r"\brm\s+.*-[^\s]*r[^\s]*f[^\s]*\s+\.\./", "Blocked: rm -rf on parent directory"),
80
+ (r"\bfind\s+.*-exec\s+rm\b", "Blocked: find -exec rm is dangerous"),
81
+ (r"\bfind\s+.*-delete\b", "Blocked: find -delete is dangerous"),
82
+ # Git history destruction
83
+ (r"\bgit\s+push\s+-f\b", "Blocked: bare force push - specify remote and branch"),
84
+ (
85
+ r"\bgit\s+push\s+--force\b",
86
+ "Blocked: bare force push - specify remote and branch",
87
+ ),
88
+ (
89
+ r"\bgit\s+clean\s+-[^\s]*f",
90
+ "Blocked: git clean -f removes untracked files permanently",
91
+ ),
64
92
  ]
65
93
 
66
94
 
@@ -89,17 +117,15 @@ def main():
89
117
 
90
118
  if is_dangerous:
91
119
  # Output error message and exit 2 to block
92
- print(json.dumps({
93
- "error": message
94
- }))
120
+ print(json.dumps({"error": message}))
95
121
  sys.exit(2)
96
122
 
97
123
  # Allow command to proceed
98
124
  sys.exit(0)
99
125
 
100
126
  except json.JSONDecodeError:
101
- # If we can't parse input, allow by default
102
- sys.exit(0)
127
+ # Fail closed: can't parse means can't verify safety
128
+ sys.exit(2)
103
129
  except Exception as e:
104
130
  # Log error but don't block on hook failure
105
131
  print(f"Hook error: {e}", file=sys.stderr)
@@ -0,0 +1,42 @@
1
+ # notify-hook
2
+
3
+ Ultra-lightweight Claude Code plugin that sends a desktop notification and audio chime when Claude finishes responding. No scripts — just a single hook definition that calls the `claude-notify` binary.
4
+
5
+ ## What It Does
6
+
7
+ When Claude stops responding (Stop hook), it runs the `claude-notify` command to:
8
+ 1. Send a desktop notification
9
+ 2. Play an audio chime
10
+
11
+ This lets you switch to other tasks while Claude works and get alerted when it needs your attention.
12
+
13
+ ## How It Works
14
+
15
+ ### Hook Lifecycle
16
+
17
+ ```
18
+ Claude stops responding (Stop event)
19
+
20
+ └─→ claude-notify command fires
21
+
22
+ ├─→ Desktop notification sent
23
+ └─→ Audio chime played
24
+ ```
25
+
26
+ The hook has a 5-second timeout. The plugin contains no scripts of its own — it delegates entirely to the `claude-notify` binary.
27
+
28
+ ## Plugin Structure
29
+
30
+ ```
31
+ notify-hook/
32
+ ├── .claude-plugin/
33
+ │ └── plugin.json # Plugin metadata
34
+ ├── hooks/
35
+ │ └── hooks.json # Stop hook registration
36
+ └── README.md # This file
37
+ ```
38
+
39
+ ## Requirements
40
+
41
+ - Claude Code with plugin hook support
42
+ - The `notify-hook` devcontainer feature must be installed (provides the `claude-notify` binary)