moai-adk 0.4.5__py3-none-any.whl → 0.4.8__py3-none-any.whl
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.
Potentially problematic release.
This version of moai-adk might be problematic. Click here for more details.
- moai_adk/__init__.py +1 -1
- moai_adk/core/project/initializer.py +12 -5
- moai_adk/templates/.claude/agents/alfred/cc-manager.md +188 -954
- moai_adk/templates/.claude/agents/alfred/debug-helper.md +4 -5
- moai_adk/templates/.claude/agents/alfred/doc-syncer.md +2 -2
- moai_adk/templates/.claude/agents/alfred/git-manager.md +2 -2
- moai_adk/templates/.claude/agents/alfred/implementation-planner.md +3 -3
- moai_adk/templates/.claude/agents/alfred/project-manager.md +6 -6
- moai_adk/templates/.claude/agents/alfred/quality-gate.md +4 -6
- moai_adk/templates/.claude/agents/alfred/skill-factory.md +829 -0
- moai_adk/templates/.claude/agents/alfred/spec-builder.md +2 -2
- moai_adk/templates/.claude/agents/alfred/tag-agent.md +2 -2
- moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +3 -3
- moai_adk/templates/.claude/agents/alfred/trust-checker.md +5 -5
- moai_adk/templates/.claude/commands/alfred/0-project.md +98 -42
- moai_adk/templates/.claude/commands/alfred/1-plan.md +7 -7
- moai_adk/templates/.claude/commands/alfred/2-run.md +36 -36
- moai_adk/templates/.claude/commands/alfred/3-sync.md +10 -10
- moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +14 -1
- moai_adk/templates/.claude/hooks/alfred/core/__init__.py +115 -33
- moai_adk/templates/.claude/hooks/alfred/handlers/session.py +8 -9
- moai_adk/templates/.claude/hooks/alfred/handlers/tool.py +6 -6
- moai_adk/templates/.claude/hooks/alfred/handlers/user.py +5 -4
- moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +1 -1
- moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +1 -1
- moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +1 -1
- moai_adk/templates/.claude/settings.json +42 -2
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +76 -66
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +86 -59
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/reference.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +480 -0
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +257 -0
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +120 -0
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +87 -73
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +78 -62
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +78 -55
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +78 -64
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +249 -0
- moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +32 -0
- moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +278 -0
- moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +26 -0
- moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +287 -0
- moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +21 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +232 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +19 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +19 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +24 -0
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +179 -0
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +39 -0
- moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +296 -0
- moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +18 -0
- moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +243 -0
- moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +30 -0
- moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +271 -0
- moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +15 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +234 -43
- moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +1633 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +660 -0
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +97 -69
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +97 -72
- moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-domain-database/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-database/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +98 -73
- moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +97 -73
- moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +97 -67
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +97 -79
- moai_adk/templates/.claude/skills/moai-domain-security/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-security/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +97 -71
- moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +656 -60
- moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +1107 -0
- moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +1533 -0
- moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +87 -78
- moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +87 -70
- moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +87 -86
- moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +77 -62
- moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +88 -56
- moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +90 -71
- moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +78 -58
- moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +78 -51
- moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +253 -32
- moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +1099 -0
- moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-c/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-c/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +98 -76
- moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +86 -61
- moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-go/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-go/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +87 -61
- moai_adk/templates/.claude/skills/moai-lang-java/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-java/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +88 -59
- moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +32 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +98 -73
- moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +86 -61
- moai_adk/templates/.claude/skills/moai-lang-php/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-php/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +388 -53
- moai_adk/templates/.claude/skills/moai-lang-python/examples.md +624 -0
- moai_adk/templates/.claude/skills/moai-lang-python/reference.md +316 -0
- moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +97 -73
- moai_adk/templates/.claude/skills/moai-lang-r/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-r/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +98 -73
- moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +97 -73
- moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +90 -59
- moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +34 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/CHECKLIST.md +482 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/EXAMPLES.md +278 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/INTERACTIVE-DISCOVERY.md +524 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/METADATA.md +477 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/PARALLEL-ANALYSIS-REPORT.md +429 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/PYTHON-VERSION-MATRIX.md +391 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL-FACTORY-WORKFLOW.md +431 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL-UPDATE-ADVISOR.md +577 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL.md +560 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/STEP-BY-STEP-GUIDE.md +466 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/STRUCTURE.md +583 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/WEB-RESEARCH.md +526 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/reference.md +465 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/scripts/generate-structure.sh +328 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/scripts/validate-skill.sh +312 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/SKILL_TEMPLATE.md +245 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/examples-template.md +285 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/reference-template.md +278 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/scripts-template.sh +303 -0
- moai_adk/templates/.claude/skills/moai-spec-authoring/README.md +129 -0
- moai_adk/templates/.claude/skills/moai-spec-authoring/SKILL.md +1300 -0
- moai_adk/templates/.claude/skills/moai-spec-authoring/examples/validate-spec.sh +161 -0
- moai_adk/templates/CLAUDE.md +121 -81
- moai_adk-0.4.8.dist-info/METADATA +1553 -0
- moai_adk-0.4.8.dist-info/RECORD +265 -0
- moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/SKILL.md +0 -112
- moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/SKILL.md +0 -103
- moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/SKILL.md +0 -105
- moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/SKILL.md +0 -97
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/SKILL.md +0 -87
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/examples.md +0 -62
- moai_adk/templates/.claude/skills/moai-claude-code/SKILL.md +0 -94
- moai_adk/templates/.claude/skills/moai-claude-code/examples.md +0 -513
- moai_adk/templates/.claude/skills/moai-claude-code/reference.md +0 -433
- moai_adk/templates/.claude/skills/moai-claude-code/templates/agent-full.md +0 -332
- moai_adk/templates/.claude/skills/moai-claude-code/templates/command-full.md +0 -384
- moai_adk/templates/.claude/skills/moai-claude-code/templates/plugin-full.json +0 -363
- moai_adk/templates/.claude/skills/moai-claude-code/templates/settings-full.json +0 -595
- moai_adk/templates/.claude/skills/moai-claude-code/templates/skill-full.md +0 -496
- moai_adk/templates/.claude/skills/moai-lang-clojure/SKILL.md +0 -100
- moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +0 -99
- moai_adk/templates/.claude/skills/moai-lang-haskell/SKILL.md +0 -100
- moai_adk/templates/.claude/skills/moai-lang-julia/SKILL.md +0 -98
- moai_adk/templates/.claude/skills/moai-lang-lua/SKILL.md +0 -98
- moai_adk-0.4.5.dist-info/METADATA +0 -369
- moai_adk-0.4.5.dist-info/RECORD +0 -152
- {moai_adk-0.4.5.dist-info → moai_adk-0.4.8.dist-info}/WHEEL +0 -0
- {moai_adk-0.4.5.dist-info → moai_adk-0.4.8.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.4.5.dist-info → moai_adk-0.4.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "Designing Slash Commands for Claude Code"
|
|
3
|
+
description: "Create and optimize slash commands with proper argument parsing, tool permissions, and agent orchestration. Use when building workflow entry points, automation commands, or user-facing shortcuts."
|
|
4
|
+
allowed-tools: "Read, Write, Edit, Glob, Bash"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Designing Slash Commands
|
|
8
|
+
|
|
9
|
+
Slash commands are user-facing entry points that orchestrate sub-agents, manage approvals, and coordinate multi-step workflows. They follow the Plan → Execute → Sync cadence.
|
|
10
|
+
|
|
11
|
+
## Command File Structure
|
|
12
|
+
|
|
13
|
+
**Location**: `.claude/commands/`
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
---
|
|
17
|
+
name: command-name
|
|
18
|
+
description: Brief description of what the command does
|
|
19
|
+
argument-hint: "[param1] [param2] [optional-param]"
|
|
20
|
+
tools: Read, Write, Task, Bash(git:*)
|
|
21
|
+
model: sonnet
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# Command Title
|
|
25
|
+
|
|
26
|
+
Brief description of functionality.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
- `/command-name param1 param2` — Basic usage
|
|
31
|
+
- Parameter descriptions
|
|
32
|
+
- Expected behavior
|
|
33
|
+
|
|
34
|
+
## Agent Orchestration
|
|
35
|
+
|
|
36
|
+
1. Call specific agent for task
|
|
37
|
+
2. Handle results
|
|
38
|
+
3. Provide user feedback
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Command Design Patterns
|
|
42
|
+
|
|
43
|
+
### Pattern 1: Planning Command
|
|
44
|
+
```yaml
|
|
45
|
+
---
|
|
46
|
+
name: /alfred:1-plan
|
|
47
|
+
description: Write SPEC requirements in EARS syntax
|
|
48
|
+
argument-hint: "[title]"
|
|
49
|
+
tools: Read, Write, Task
|
|
50
|
+
model: sonnet
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
# SPEC Planning Command
|
|
54
|
+
|
|
55
|
+
Initiates SPEC authoring via spec-builder sub-agent.
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
`/alfred:1-plan "User authentication system"`
|
|
60
|
+
|
|
61
|
+
## Agent Orchestration
|
|
62
|
+
|
|
63
|
+
1. Invoke spec-builder agent
|
|
64
|
+
2. Gather requirements via EARS patterns
|
|
65
|
+
3. Create SPEC file in `.moai/specs/`
|
|
66
|
+
4. Suggest next step: `/alfred:2-run`
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Pattern 2: Code Review Command
|
|
70
|
+
```yaml
|
|
71
|
+
---
|
|
72
|
+
name: /review-code
|
|
73
|
+
description: Trigger automated code review with quality analysis
|
|
74
|
+
argument-hint: "[file-pattern] [--strict]"
|
|
75
|
+
tools: Read, Glob, Grep, Task
|
|
76
|
+
model: sonnet
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
# Code Review Command
|
|
80
|
+
|
|
81
|
+
Analyzes code quality against TRUST 5 principles.
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
- `/review-code src/**/*.ts` — Review TypeScript files
|
|
86
|
+
- `/review-code . --strict` — Strict mode (fail on warnings)
|
|
87
|
+
|
|
88
|
+
## Agent Orchestration
|
|
89
|
+
|
|
90
|
+
1. Scan files matching pattern
|
|
91
|
+
2. Invoke code-reviewer agent
|
|
92
|
+
3. Generate report with findings
|
|
93
|
+
4. Suggest fixes with severity levels
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Pattern 3: Deployment Command
|
|
97
|
+
```yaml
|
|
98
|
+
---
|
|
99
|
+
name: /deploy
|
|
100
|
+
description: Deploy application with safety gates
|
|
101
|
+
argument-hint: "[env] [--force]"
|
|
102
|
+
tools: Read, Write, Task, Bash(git:*)
|
|
103
|
+
model: haiku
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
# Deployment Command
|
|
107
|
+
|
|
108
|
+
Orchestrates multi-step deployment with approval gates.
|
|
109
|
+
|
|
110
|
+
## Usage
|
|
111
|
+
|
|
112
|
+
- `/deploy staging` — Deploy to staging
|
|
113
|
+
- `/deploy production --force` — Force production deploy
|
|
114
|
+
|
|
115
|
+
## Agent Orchestration
|
|
116
|
+
|
|
117
|
+
1. Validate deployment readiness
|
|
118
|
+
2. Run pre-deployment checks
|
|
119
|
+
3. Ask for user approval
|
|
120
|
+
4. Execute deployment
|
|
121
|
+
5. Monitor post-deployment
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Argument Parsing Pattern
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Inside command execution
|
|
128
|
+
$ARGUMENTS # Entire argument string
|
|
129
|
+
$1, $2, $3 # Individual arguments
|
|
130
|
+
$@ # All arguments as array
|
|
131
|
+
|
|
132
|
+
# Example: /my-command arg1 arg2 --flag
|
|
133
|
+
# $ARGUMENTS = "arg1 arg2 --flag"
|
|
134
|
+
# $1 = "arg1"
|
|
135
|
+
# $2 = "arg2"
|
|
136
|
+
# $3 = "--flag"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## High-Freedom: Orchestration Strategies
|
|
140
|
+
|
|
141
|
+
### Sequential Execution
|
|
142
|
+
```
|
|
143
|
+
Command: /plan-and-implement
|
|
144
|
+
├─ Phase 1: spec-builder (SPEC creation)
|
|
145
|
+
└─ Phase 2: code-builder (TDD implementation)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Parallel Execution
|
|
149
|
+
```
|
|
150
|
+
Command: /analyze-project
|
|
151
|
+
├─ Agent 1: security-auditor (vulnerability scan)
|
|
152
|
+
├─ Agent 2: performance-analyzer (bottleneck detection)
|
|
153
|
+
└─ Agent 3: architecture-reviewer (design review)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Conditional Branching
|
|
157
|
+
```
|
|
158
|
+
Command: /fix-errors
|
|
159
|
+
├─ Check: Are tests failing?
|
|
160
|
+
│ ├─ YES → debug-helper agent
|
|
161
|
+
│ └─ NO → suggest next steps
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Medium-Freedom: Command Templates
|
|
165
|
+
|
|
166
|
+
### Status Check Command
|
|
167
|
+
```yaml
|
|
168
|
+
name: /status
|
|
169
|
+
description: Show project status summary
|
|
170
|
+
argument-hint: "[--verbose]"
|
|
171
|
+
tools: Read, Bash(git:*)
|
|
172
|
+
model: haiku
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
# Status Check
|
|
176
|
+
|
|
177
|
+
Displays project health: SPEC status, test results, Git state.
|
|
178
|
+
|
|
179
|
+
## Checks
|
|
180
|
+
|
|
181
|
+
1. SPEC completeness
|
|
182
|
+
2. Test coverage
|
|
183
|
+
3. Git branch status
|
|
184
|
+
4. Recent commits
|
|
185
|
+
5. TODO items
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Bulk Operation Command
|
|
189
|
+
```yaml
|
|
190
|
+
name: /migrate
|
|
191
|
+
description: Run migration across multiple files
|
|
192
|
+
argument-hint: "[from] [to] [--preview]"
|
|
193
|
+
tools: Read, Glob, Bash
|
|
194
|
+
model: sonnet
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
# Migration Command
|
|
198
|
+
|
|
199
|
+
Migrates code patterns across project.
|
|
200
|
+
|
|
201
|
+
## Usage
|
|
202
|
+
|
|
203
|
+
- `/migrate v1-api v2-api --preview` — Show changes without applying
|
|
204
|
+
- `/migrate v1-api v2-api` — Apply migration
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Low-Freedom: Safety & Approval Patterns
|
|
208
|
+
|
|
209
|
+
### Approval Gate Pattern
|
|
210
|
+
```bash
|
|
211
|
+
# Inside command execution
|
|
212
|
+
|
|
213
|
+
echo "🔴 This action is destructive. Review carefully:"
|
|
214
|
+
echo " • Will delete 10 files"
|
|
215
|
+
echo " • Cannot be undone"
|
|
216
|
+
echo ""
|
|
217
|
+
read -p "Type 'yes' to confirm: " confirm
|
|
218
|
+
|
|
219
|
+
if [[ "$confirm" != "yes" ]]; then
|
|
220
|
+
echo "❌ Cancelled"
|
|
221
|
+
exit 1
|
|
222
|
+
fi
|
|
223
|
+
|
|
224
|
+
# Execute dangerous operation
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Dry-Run Pattern
|
|
228
|
+
```bash
|
|
229
|
+
if [[ "${3:-}" == "--preview" ]]; then
|
|
230
|
+
echo "🔍 Preview mode (no changes)"
|
|
231
|
+
# Show what would happen
|
|
232
|
+
exit 0
|
|
233
|
+
fi
|
|
234
|
+
|
|
235
|
+
# Execute actual changes
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Command Registry
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# List all commands
|
|
242
|
+
/commands
|
|
243
|
+
|
|
244
|
+
# View command details
|
|
245
|
+
/commands view /deploy
|
|
246
|
+
|
|
247
|
+
# Create new command
|
|
248
|
+
/commands create
|
|
249
|
+
|
|
250
|
+
# Edit command
|
|
251
|
+
/commands edit /deploy
|
|
252
|
+
|
|
253
|
+
# Delete command
|
|
254
|
+
/commands delete /deploy
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Command Validation Checklist
|
|
258
|
+
|
|
259
|
+
- [ ] `name` is kebab-case (e.g., `/review-code`)
|
|
260
|
+
- [ ] `description` clearly explains purpose
|
|
261
|
+
- [ ] `argument-hint` shows expected parameters
|
|
262
|
+
- [ ] `tools` list is minimal and justified
|
|
263
|
+
- [ ] `model` is `haiku` or `sonnet`
|
|
264
|
+
- [ ] Agent orchestration is clearly defined
|
|
265
|
+
- [ ] Arguments are properly parsed
|
|
266
|
+
- [ ] Safety gates are in place for dangerous operations
|
|
267
|
+
- [ ] Feedback to user is clear and actionable
|
|
268
|
+
|
|
269
|
+
## Best Practices
|
|
270
|
+
|
|
271
|
+
✅ **DO**:
|
|
272
|
+
- Design commands around workflows, not tools
|
|
273
|
+
- Use agents for complex logic
|
|
274
|
+
- Include preview/dry-run modes for risky operations
|
|
275
|
+
- Provide clear feedback at each step
|
|
276
|
+
- Link to next command in suggestions
|
|
277
|
+
|
|
278
|
+
❌ **DON'T**:
|
|
279
|
+
- Make commands do too much (limit to 1 coherent workflow)
|
|
280
|
+
- Require multiple parameters without defaults
|
|
281
|
+
- Skip approval gates for destructive operations
|
|
282
|
+
- Leave users guessing what happened
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
**Reference**: Claude Code Slash Commands documentation
|
|
287
|
+
**Version**: 1.0.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: command-name
|
|
3
|
+
description: Brief description of what the command does
|
|
4
|
+
argument-hint: "[param1] [param2]"
|
|
5
|
+
tools: Read, Write, Task
|
|
6
|
+
model: sonnet
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Command Title
|
|
10
|
+
|
|
11
|
+
Brief description of functionality.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
`/command-name param1 param2` — Basic usage
|
|
16
|
+
|
|
17
|
+
## Agent Orchestration
|
|
18
|
+
|
|
19
|
+
1. Call specific agent for task
|
|
20
|
+
2. Handle results
|
|
21
|
+
3. Provide user feedback
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "Configuring Claude Code Hooks System"
|
|
3
|
+
description: "Design, implement, and manage PreToolUse/PostToolUse/SessionStart/Notification/Stop hooks. Use when enforcing safety checks, auto-formatting, running linters, or triggering automated workflows based on development events."
|
|
4
|
+
allowed-tools: "Read, Write, Edit, Glob, Bash"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Configuring Claude Code Hooks System
|
|
8
|
+
|
|
9
|
+
Hooks are lightweight (<100ms) automated scripts triggered by Claude Code lifecycle events. They enforce guardrails, run quality checks, and seed context without blocking user workflow.
|
|
10
|
+
|
|
11
|
+
## Hook Types & Events
|
|
12
|
+
|
|
13
|
+
| Hook Type | Trigger Event | Execution Time | Use Cases |
|
|
14
|
+
|-----------|---------------|-----------------|-----------|
|
|
15
|
+
| **PreToolUse** | Before tool execution (Read, Edit, Bash, etc.) | <100ms | Command validation, permission checks, safety gates |
|
|
16
|
+
| **PostToolUse** | After tool execution succeeds | <100ms | Auto-formatting, linting, permission restoration |
|
|
17
|
+
| **SessionStart** | Session initialization | <500ms | Project summary, context seeding, status card |
|
|
18
|
+
| **Notification** | User notification event | N/A | macOS notifications, alerts, wait status |
|
|
19
|
+
| **Stop** | Session termination | N/A | Cleanup, final checks, task summary |
|
|
20
|
+
|
|
21
|
+
## Hook Configuration in settings.json
|
|
22
|
+
|
|
23
|
+
### High-Freedom Approach: Events-Driven Hooks
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"hooks": {
|
|
28
|
+
"PreToolUse": [
|
|
29
|
+
{
|
|
30
|
+
"matcher": "Bash",
|
|
31
|
+
"hooks": [
|
|
32
|
+
{
|
|
33
|
+
"type": "command",
|
|
34
|
+
"command": "node ~/.claude/hooks/pre-bash-validator.js"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"matcher": "Edit|Write",
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "bash ~/.claude/hooks/pre-edit-guard.sh"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"PostToolUse": [
|
|
49
|
+
{
|
|
50
|
+
"matcher": "Edit",
|
|
51
|
+
"hooks": [
|
|
52
|
+
{
|
|
53
|
+
"type": "command",
|
|
54
|
+
"command": "bash ~/.claude/hooks/post-edit-lint.sh"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"SessionStart": [
|
|
60
|
+
{
|
|
61
|
+
"matcher": "*",
|
|
62
|
+
"hooks": [
|
|
63
|
+
{
|
|
64
|
+
"type": "command",
|
|
65
|
+
"command": "node ~/.claude/hooks/session-status-card.js"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Medium-Freedom: Hook Patterns
|
|
75
|
+
|
|
76
|
+
### Pattern 1: Pre-Command Validation
|
|
77
|
+
```bash
|
|
78
|
+
#!/bin/bash
|
|
79
|
+
# pre-bash-validator.sh: Block dangerous patterns
|
|
80
|
+
|
|
81
|
+
FORBIDDEN_PATTERNS=(
|
|
82
|
+
"rm -rf /"
|
|
83
|
+
"sudo rm"
|
|
84
|
+
"chmod 777 /"
|
|
85
|
+
"eval \$(curl"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
COMMAND="$1"
|
|
89
|
+
for pattern in "${FORBIDDEN_PATTERNS[@]}"; do
|
|
90
|
+
if [[ "$COMMAND" =~ $pattern ]]; then
|
|
91
|
+
echo "🔴 Blocked: $pattern detected" >&2
|
|
92
|
+
exit 2 # Block execution
|
|
93
|
+
fi
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
exit 0 # Allow execution
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Pattern 2: Post-Edit Auto-Formatting
|
|
100
|
+
```bash
|
|
101
|
+
#!/bin/bash
|
|
102
|
+
# post-edit-format.sh: Auto-format after edits
|
|
103
|
+
|
|
104
|
+
FILE="$1"
|
|
105
|
+
EXT="${FILE##*.}"
|
|
106
|
+
|
|
107
|
+
case "$EXT" in
|
|
108
|
+
js|ts)
|
|
109
|
+
npx prettier --write "$FILE" 2>/dev/null
|
|
110
|
+
;;
|
|
111
|
+
py)
|
|
112
|
+
python3 -m black "$FILE" 2>/dev/null
|
|
113
|
+
;;
|
|
114
|
+
go)
|
|
115
|
+
gofmt -w "$FILE" 2>/dev/null
|
|
116
|
+
;;
|
|
117
|
+
esac
|
|
118
|
+
|
|
119
|
+
exit 0
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Pattern 3: SessionStart Status Card
|
|
123
|
+
```bash
|
|
124
|
+
#!/bin/bash
|
|
125
|
+
# session-status-card.sh: Show project status
|
|
126
|
+
|
|
127
|
+
echo "🚀 Claude Code Session Started"
|
|
128
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
129
|
+
|
|
130
|
+
if [ -f ".moai/config.json" ]; then
|
|
131
|
+
PROJECT=$(jq -r '.name' .moai/config.json 2>/dev/null || echo "Unknown")
|
|
132
|
+
echo "📦 Project: $PROJECT"
|
|
133
|
+
echo "🏗️ Framework: $(jq -r '.tech_stack' .moai/config.json 2>/dev/null || echo "Auto-detect")"
|
|
134
|
+
fi
|
|
135
|
+
|
|
136
|
+
echo "📋 Recent SPECS:"
|
|
137
|
+
ls .moai/specs/ 2>/dev/null | head -3 | sed 's/^/ ✓ /'
|
|
138
|
+
|
|
139
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Low-Freedom: Security-Focused Hook Scripts
|
|
143
|
+
|
|
144
|
+
### Permission Preservation Hook
|
|
145
|
+
```bash
|
|
146
|
+
#!/bin/bash
|
|
147
|
+
set -euo pipefail
|
|
148
|
+
# preserve-permissions.sh: Save/restore file permissions
|
|
149
|
+
|
|
150
|
+
HOOK_TYPE="${1:-pre}" # 'pre' or 'post'
|
|
151
|
+
FILE="${2:-.}"
|
|
152
|
+
|
|
153
|
+
PERMS_FILE="/tmp/perms_${FILE//\//_}.txt"
|
|
154
|
+
|
|
155
|
+
if [[ "$HOOK_TYPE" == "pre" ]]; then
|
|
156
|
+
stat -c "%a %u:%g" "$FILE" > "$PERMS_FILE" 2>/dev/null || true
|
|
157
|
+
exit 0
|
|
158
|
+
elif [[ "$HOOK_TYPE" == "post" ]]; then
|
|
159
|
+
if [[ -f "$PERMS_FILE" ]]; then
|
|
160
|
+
SAVED_PERMS=$(cat "$PERMS_FILE")
|
|
161
|
+
chmod ${SAVED_PERMS%% *} "$FILE" 2>/dev/null || true
|
|
162
|
+
rm "$PERMS_FILE"
|
|
163
|
+
fi
|
|
164
|
+
exit 0
|
|
165
|
+
fi
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Dangerous Command Blocker
|
|
169
|
+
```python
|
|
170
|
+
#!/usr/bin/env python3
|
|
171
|
+
import json
|
|
172
|
+
import sys
|
|
173
|
+
import re
|
|
174
|
+
|
|
175
|
+
BLOCKED_PATTERNS = [
|
|
176
|
+
(r"rm\s+-rf\s+/", "Blocking rm -rf /"),
|
|
177
|
+
(r"sudo\s+rm", "Blocking sudo rm without confirmation"),
|
|
178
|
+
(r">\s*/etc/\w+", "Blocking writes to system files"),
|
|
179
|
+
(r"curl.*\|\s*bash", "Blocking curl | bash (code injection risk)"),
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
try:
|
|
183
|
+
data = json.load(sys.stdin)
|
|
184
|
+
command = data.get("tool_input", {}).get("command", "")
|
|
185
|
+
|
|
186
|
+
for pattern, msg in BLOCKED_PATTERNS:
|
|
187
|
+
if re.search(pattern, command):
|
|
188
|
+
print(f"🔴 BLOCKED: {msg}", file=sys.stderr)
|
|
189
|
+
sys.exit(2) # Block
|
|
190
|
+
|
|
191
|
+
sys.exit(0) # Allow
|
|
192
|
+
except Exception as e:
|
|
193
|
+
print(f"Hook error: {e}", file=sys.stderr)
|
|
194
|
+
sys.exit(0) # Allow on error (fail open)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Hook Exit Codes
|
|
198
|
+
|
|
199
|
+
| Code | Meaning | Behavior |
|
|
200
|
+
|------|---------|----------|
|
|
201
|
+
| `0` | Success | Tool proceeds normally |
|
|
202
|
+
| `1` | Warning + Stderr | Warning logged, tool proceeds |
|
|
203
|
+
| `2` | Blocked + Error | Tool execution blocked |
|
|
204
|
+
|
|
205
|
+
## Best Practices
|
|
206
|
+
|
|
207
|
+
✅ **DO**:
|
|
208
|
+
- Keep hook scripts < 100ms execution time
|
|
209
|
+
- Use specific matchers (not wildcard `*` unless necessary)
|
|
210
|
+
- Log errors clearly to stderr
|
|
211
|
+
- Test hooks before deploying to team
|
|
212
|
+
|
|
213
|
+
❌ **DON'T**:
|
|
214
|
+
- Make network calls in PreToolUse hooks
|
|
215
|
+
- Block common operations (use warnings instead)
|
|
216
|
+
- Write to user files from hooks
|
|
217
|
+
- Create complex logic (delegate to sub-agents)
|
|
218
|
+
|
|
219
|
+
## Hook Validation Checklist
|
|
220
|
+
|
|
221
|
+
- [ ] All scripts have proper shebang (`#!/bin/bash` or `#!/usr/bin/env python3`)
|
|
222
|
+
- [ ] Scripts are executable: `chmod +x hook.sh`
|
|
223
|
+
- [ ] Exit codes are correct (0, 1, or 2)
|
|
224
|
+
- [ ] Paths are absolute (not relative)
|
|
225
|
+
- [ ] Tested for < 100ms latency
|
|
226
|
+
- [ ] Error messages are user-friendly
|
|
227
|
+
- [ ] No hardcoded secrets or credentials
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
**Reference**: Context7 Claude Code Hooks documentation
|
|
232
|
+
**Version**: 1.0.0
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Pre-Bash Command Validator (from Context7 official docs)
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
FORBIDDEN=(
|
|
6
|
+
"rm -rf /"
|
|
7
|
+
"sudo rm"
|
|
8
|
+
"chmod 777"
|
|
9
|
+
"eval.*curl"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
COMMAND="${1:-}"
|
|
13
|
+
for pattern in "${FORBIDDEN[@]}"; do
|
|
14
|
+
if [[ "$COMMAND" =~ $pattern ]]; then
|
|
15
|
+
echo "🔴 BLOCKED: $pattern" >&2
|
|
16
|
+
exit 2
|
|
17
|
+
fi
|
|
18
|
+
done
|
|
19
|
+
exit 0
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Preserve file permissions (from Context7 official docs)
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
HOOK_TYPE="${1:-pre}"
|
|
6
|
+
FILE="${2:-.}"
|
|
7
|
+
PERMS_FILE="/tmp/perms_${FILE//\//_}.txt"
|
|
8
|
+
|
|
9
|
+
if [[ "$HOOK_TYPE" == "pre" ]]; then
|
|
10
|
+
stat -c "%a %u:%g" "$FILE" > "$PERMS_FILE" 2>/dev/null || true
|
|
11
|
+
exit 0
|
|
12
|
+
elif [[ "$HOOK_TYPE" == "post" ]]; then
|
|
13
|
+
if [[ -f "$PERMS_FILE" ]]; then
|
|
14
|
+
SAVED=$(cat "$PERMS_FILE")
|
|
15
|
+
chmod ${SAVED%% *} "$FILE" 2>/dev/null || true
|
|
16
|
+
rm "$PERMS_FILE"
|
|
17
|
+
fi
|
|
18
|
+
exit 0
|
|
19
|
+
fi
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Bash command validator (from Context7 official docs)
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
BLOCKED = [
|
|
8
|
+
(r"rm\s+-rf\s+/", "Blocking rm -rf /"),
|
|
9
|
+
(r"sudo\s+rm", "Blocking sudo rm"),
|
|
10
|
+
(r">\s*/etc/\w+", "Blocking writes to /etc"),
|
|
11
|
+
(r"curl.*\|\s*bash", "Blocking curl | bash"),
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
data = json.load(sys.stdin)
|
|
16
|
+
cmd = data.get("tool_input", {}).get("command", "")
|
|
17
|
+
|
|
18
|
+
for pattern, msg in BLOCKED:
|
|
19
|
+
if re.search(pattern, cmd):
|
|
20
|
+
print(f"🔴 {msg}", file=sys.stderr)
|
|
21
|
+
sys.exit(2)
|
|
22
|
+
sys.exit(0)
|
|
23
|
+
except:
|
|
24
|
+
sys.exit(0)
|