panopticon-cli 0.4.6 → 0.4.8

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 (114) hide show
  1. package/package.json +3 -2
  2. package/scripts/heartbeat-hook +149 -0
  3. package/scripts/install-git-hooks.sh +66 -0
  4. package/scripts/notify-complete +79 -0
  5. package/scripts/postinstall.mjs +49 -0
  6. package/scripts/pre-tool-hook +60 -0
  7. package/scripts/record-cost-event.js +94 -0
  8. package/scripts/record-cost-event.ts +113 -0
  9. package/scripts/restart-dashboard.sh +59 -0
  10. package/scripts/setup-certs.sh +66 -0
  11. package/scripts/specialist-stop-hook +106 -0
  12. package/scripts/stop-hook +58 -0
  13. package/scripts/validate-merge.sh +119 -0
  14. package/skills/beads/README.md +120 -0
  15. package/skills/beads/SKILL.md +214 -0
  16. package/skills/beads/adr/0001-bd-prime-as-source-of-truth.md +59 -0
  17. package/skills/beads/resources/AGENTS.md +62 -0
  18. package/skills/beads/resources/ASYNC_GATES.md +168 -0
  19. package/skills/beads/resources/BOUNDARIES.md +469 -0
  20. package/skills/beads/resources/CHEMISTRY_PATTERNS.md +197 -0
  21. package/skills/beads/resources/CLI_REFERENCE.md +558 -0
  22. package/skills/beads/resources/DEPENDENCIES.md +747 -0
  23. package/skills/beads/resources/INTEGRATION_PATTERNS.md +407 -0
  24. package/skills/beads/resources/ISSUE_CREATION.md +139 -0
  25. package/skills/beads/resources/MOLECULES.md +354 -0
  26. package/skills/beads/resources/PATTERNS.md +341 -0
  27. package/skills/beads/resources/RESUMABILITY.md +207 -0
  28. package/skills/beads/resources/STATIC_DATA.md +54 -0
  29. package/skills/beads/resources/TROUBLESHOOTING.md +489 -0
  30. package/skills/beads/resources/WORKFLOWS.md +623 -0
  31. package/skills/beads/resources/WORKTREES.md +94 -0
  32. package/skills/beads-completion-check/SKILL.md +90 -0
  33. package/skills/beads-panopticon-guide/SKILL.md +171 -0
  34. package/skills/bug-fix/SKILL.md +32 -0
  35. package/skills/clear-writing/SKILL.md +105 -0
  36. package/skills/clear-writing/references/elements-of-style/01-introductory.md +3 -0
  37. package/skills/clear-writing/references/elements-of-style/02-elementary-rules-of-usage.md +214 -0
  38. package/skills/clear-writing/references/elements-of-style/03-elementary-principles-of-composition.md +398 -0
  39. package/skills/clear-writing/references/elements-of-style/04-a-few-matters-of-form.md +89 -0
  40. package/skills/clear-writing/references/elements-of-style/05-words-and-expressions-commonly-misused.md +342 -0
  41. package/skills/clear-writing/references/signs-of-ai-writing.md +901 -0
  42. package/skills/code-review/SKILL.md +37 -0
  43. package/skills/code-review-performance/SKILL.md +53 -0
  44. package/skills/code-review-security/SKILL.md +35 -0
  45. package/skills/dependency-update/SKILL.md +30 -0
  46. package/skills/feature-work/SKILL.md +39 -0
  47. package/skills/incident-response/SKILL.md +32 -0
  48. package/skills/knowledge-capture/SKILL.md +463 -0
  49. package/skills/onboard-codebase/SKILL.md +34 -0
  50. package/skills/opus-plan/SKILL.md +400 -0
  51. package/skills/pan-approve/SKILL.md +136 -0
  52. package/skills/pan-code-review/SKILL.md +249 -0
  53. package/skills/pan-config/SKILL.md +164 -0
  54. package/skills/pan-convoy-synthesis/SKILL.md +249 -0
  55. package/skills/pan-diagnose/SKILL.md +360 -0
  56. package/skills/pan-docker/SKILL.md +279 -0
  57. package/skills/pan-docs/SKILL.md +113 -0
  58. package/skills/pan-down/SKILL.md +434 -0
  59. package/skills/pan-health/SKILL.md +240 -0
  60. package/skills/pan-help/SKILL.md +237 -0
  61. package/skills/pan-install/SKILL.md +339 -0
  62. package/skills/pan-issue/SKILL.md +596 -0
  63. package/skills/pan-kill/SKILL.md +172 -0
  64. package/skills/pan-logs/SKILL.md +255 -0
  65. package/skills/pan-network/SKILL.md +320 -0
  66. package/skills/pan-oversee/SKILL.md +290 -0
  67. package/skills/pan-plan/SKILL.md +521 -0
  68. package/skills/pan-projects/SKILL.md +239 -0
  69. package/skills/pan-quickstart/SKILL.md +440 -0
  70. package/skills/pan-reload/SKILL.md +44 -0
  71. package/skills/pan-rescue/SKILL.md +271 -0
  72. package/skills/pan-restart/SKILL.md +53 -0
  73. package/skills/pan-setup/SKILL.md +478 -0
  74. package/skills/pan-skill-creator/SKILL.md +168 -0
  75. package/skills/pan-skill-creator/references/output-patterns.md +141 -0
  76. package/skills/pan-skill-creator/references/workflows.md +90 -0
  77. package/skills/pan-skill-creator/scripts/init_skill.py +176 -0
  78. package/skills/pan-status/SKILL.md +493 -0
  79. package/skills/pan-subagent-creator/SKILL.md +295 -0
  80. package/skills/pan-subagent-creator/assets/validate-readonly-query.sh +35 -0
  81. package/skills/pan-subagent-creator/references/example-agents.md +308 -0
  82. package/skills/pan-subagent-creator/scripts/init_agent.py +126 -0
  83. package/skills/pan-sync/SKILL.md +272 -0
  84. package/skills/pan-tell/SKILL.md +157 -0
  85. package/skills/pan-test-config/SKILL.md +208 -0
  86. package/skills/pan-tracker/SKILL.md +288 -0
  87. package/skills/pan-up/SKILL.md +458 -0
  88. package/skills/pan-workspace-config/SKILL.md +303 -0
  89. package/skills/refactor/SKILL.md +30 -0
  90. package/skills/refactor-radar/SKILL.md +475 -0
  91. package/skills/release/SKILL.md +25 -0
  92. package/skills/send-feedback-to-agent/SKILL.md +98 -0
  93. package/skills/session-health/SKILL.md +76 -0
  94. package/skills/session-health/scripts/check_sessions.py +166 -0
  95. package/skills/skill-creator/SKILL.md +92 -0
  96. package/skills/skill-creator/scripts/init_skill.py +152 -0
  97. package/skills/skill-creator/scripts/package_skill.py +123 -0
  98. package/skills/stitch-design-md/README.md +34 -0
  99. package/skills/stitch-design-md/SKILL.md +172 -0
  100. package/skills/stitch-design-md/examples/DESIGN.md +154 -0
  101. package/skills/stitch-react-components/README.md +36 -0
  102. package/skills/stitch-react-components/SKILL.md +47 -0
  103. package/skills/stitch-react-components/examples/gold-standard-card.tsx +80 -0
  104. package/skills/stitch-react-components/package-lock.json +231 -0
  105. package/skills/stitch-react-components/package.json +16 -0
  106. package/skills/stitch-react-components/resources/architecture-checklist.md +15 -0
  107. package/skills/stitch-react-components/resources/component-template.tsx +37 -0
  108. package/skills/stitch-react-components/resources/stitch-api-reference.md +14 -0
  109. package/skills/stitch-react-components/resources/style-guide.json +27 -0
  110. package/skills/stitch-react-components/scripts/fetch-stitch.sh +30 -0
  111. package/skills/stitch-react-components/scripts/validate.js +68 -0
  112. package/skills/stitch-setup/SKILL.md +94 -0
  113. package/skills/web-design-guidelines/SKILL.md +39 -0
  114. package/skills/work-complete/SKILL.md +79 -0
@@ -0,0 +1,295 @@
1
+ ---
2
+ name: pan-subagent-creator
3
+ description: Create custom Claude Code subagents with isolated context windows, specific tool permissions, and specialized prompts. Use when users want to create a new subagent, configure agent delegation, set up task-specific agents, or define specialized assistants. Triggers on "create a subagent", "make a custom agent", "define an agent", "agent configuration", or "Task tool agent".
4
+ ---
5
+
6
+ # Subagent Creator
7
+
8
+ Create specialized subagents that handle specific tasks with their own context windows, system prompts, and tool permissions.
9
+
10
+ ## What Are Subagents?
11
+
12
+ Subagents are mini-agents with:
13
+ - **Independent context window** - Keep exploration out of main conversation
14
+ - **Custom system prompt** - Specialized behavior and expertise
15
+ - **Scoped tool permissions** - Least-privilege access
16
+ - **Model selection** - Cost optimization (Haiku for read-only, Sonnet for complex)
17
+
18
+ Claude delegates to subagents via the **Task tool** based on matching descriptions.
19
+
20
+ ## Subagent Anatomy
21
+
22
+ Subagents are Markdown files with YAML frontmatter:
23
+
24
+ ```markdown
25
+ ---
26
+ name: code-reviewer
27
+ description: Expert code review. Use proactively after code changes.
28
+ tools: Read, Grep, Glob, Bash
29
+ model: sonnet
30
+ ---
31
+
32
+ You are a senior code reviewer focusing on quality, security, and best practices.
33
+
34
+ [Instructions for the subagent...]
35
+ ```
36
+
37
+ ## Frontmatter Fields
38
+
39
+ | Field | Required | Description |
40
+ |-------|----------|-------------|
41
+ | `name` | Yes | Unique identifier (lowercase, hyphens allowed) |
42
+ | `description` | Yes | When Claude should delegate - this is how Claude decides |
43
+ | `tools` | No | Allowed tools (inherits all if omitted) |
44
+ | `disallowedTools` | No | Tools to explicitly deny |
45
+ | `model` | No | `haiku`, `sonnet`, `opus`, or `inherit` (default: sonnet) |
46
+ | `permissionMode` | No | `default`, `acceptEdits`, `dontAsk`, `bypassPermissions`, `plan` |
47
+ | `skills` | No | Skills to load at startup |
48
+ | `hooks` | No | Lifecycle hooks for validation |
49
+
50
+ ## Storage Locations
51
+
52
+ | Location | Scope | Use Case |
53
+ |----------|-------|----------|
54
+ | `.claude/agents/` | Current project | Team-shared subagents |
55
+ | `~/.claude/agents/` | All projects | Personal, reusable subagents |
56
+ | CLI `--agents` flag | Current session | Quick testing |
57
+
58
+ ## Model Selection for Cost
59
+
60
+ | Model | Cost | Best For |
61
+ |-------|------|----------|
62
+ | **Haiku** | Lowest | Read-only exploration, simple validation |
63
+ | **Sonnet** | Medium | Most tasks, good balance |
64
+ | **Opus** | Highest | Complex reasoning, critical decisions |
65
+ | **inherit** | Parent's | Match main conversation |
66
+
67
+ ## Permission Modes
68
+
69
+ ```yaml
70
+ permissionMode: default # Normal permission prompts
71
+ permissionMode: acceptEdits # Auto-accept file edits
72
+ permissionMode: dontAsk # Auto-deny all prompts
73
+ permissionMode: bypassPermissions # Skip all checks (dangerous)
74
+ permissionMode: plan # Read-only exploration mode
75
+ ```
76
+
77
+ ## Common Tool Sets
78
+
79
+ **Read-only agents:**
80
+ ```yaml
81
+ tools: Read, Grep, Glob
82
+ ```
83
+
84
+ **Code review agents:**
85
+ ```yaml
86
+ tools: Read, Grep, Glob, Bash
87
+ ```
88
+
89
+ **Full development agents:**
90
+ ```yaml
91
+ tools: Read, Write, Edit, Bash, Grep, Glob
92
+ ```
93
+
94
+ **Restricted bash (specific commands only):**
95
+ ```yaml
96
+ tools: Read, Grep, Glob, Bash(git status:*), Bash(git diff:*)
97
+ ```
98
+
99
+ ## Creation Process
100
+
101
+ ### Step 1: Define Purpose
102
+ - What specific task does this agent handle?
103
+ - What expertise should it have?
104
+ - What tools does it need (minimum necessary)?
105
+
106
+ ### Step 2: Write Description
107
+ The description is how Claude decides when to delegate. Make it specific:
108
+
109
+ **Good:** "Expert database query optimizer. Analyzes SQL queries for performance issues, suggests indexes, and rewrites slow queries."
110
+
111
+ **Bad:** "Helps with database stuff."
112
+
113
+ ### Step 3: Create Agent File
114
+
115
+ ```bash
116
+ # Project-level (shared with team)
117
+ mkdir -p .claude/agents
118
+ touch .claude/agents/my-agent.md
119
+
120
+ # User-level (personal)
121
+ mkdir -p ~/.claude/agents
122
+ touch ~/.claude/agents/my-agent.md
123
+ ```
124
+
125
+ ### Step 4: Write Instructions
126
+ Use imperative voice. Be specific about:
127
+ - What the agent should do when invoked
128
+ - How to structure output
129
+ - What to avoid
130
+ - Error handling
131
+
132
+ ### Step 5: Test Delegation
133
+ Try prompts that should and shouldn't trigger the agent. Refine description if needed.
134
+
135
+ ## Example: Code Reviewer
136
+
137
+ ```markdown
138
+ ---
139
+ name: code-reviewer
140
+ description: Expert code review specialist. Reviews code for quality, security, and maintainability. Use proactively after code changes or when user asks for review.
141
+ tools: Read, Grep, Glob, Bash
142
+ model: inherit
143
+ ---
144
+
145
+ You are a senior code reviewer ensuring high standards.
146
+
147
+ When invoked:
148
+ 1. Run `git diff` to see recent changes
149
+ 2. Focus on modified files
150
+ 3. Begin review immediately
151
+
152
+ Review checklist:
153
+ - Code is clear and readable
154
+ - Functions and variables are well-named
155
+ - No duplicated code
156
+ - Proper error handling
157
+ - No exposed secrets or API keys
158
+ - Input validation present
159
+ - Good test coverage
160
+ - Performance considered
161
+
162
+ Provide feedback by priority:
163
+ - **Critical** (must fix)
164
+ - **Warning** (should fix)
165
+ - **Suggestion** (consider)
166
+
167
+ Include specific examples of how to fix issues.
168
+ ```
169
+
170
+ ## Example: Database Read-Only Agent with Hooks
171
+
172
+ ```markdown
173
+ ---
174
+ name: db-reader
175
+ description: Execute read-only database queries. Use when user needs data analysis without modification risk.
176
+ tools: Bash
177
+ model: haiku
178
+ hooks:
179
+ PreToolUse:
180
+ - matcher: "Bash"
181
+ hooks:
182
+ - type: command
183
+ command: "./scripts/validate-readonly.sh"
184
+ ---
185
+
186
+ You are a database analyst with read-only access.
187
+ Execute SELECT queries to answer questions about data.
188
+
189
+ You cannot modify data. If asked to INSERT, UPDATE, DELETE,
190
+ or modify schema, explain you only have read access.
191
+ ```
192
+
193
+ ## Example: Test Runner
194
+
195
+ ```markdown
196
+ ---
197
+ name: test-runner
198
+ description: Run and analyze test suites. Returns only failures and summary, keeping main context clean. Use after code changes or when user asks to run tests.
199
+ tools: Bash, Read, Grep
200
+ model: haiku
201
+ ---
202
+
203
+ You are a test execution specialist.
204
+
205
+ When invoked:
206
+ 1. Identify test framework (jest, pytest, vitest, etc.)
207
+ 2. Run full test suite
208
+ 3. Analyze failures
209
+ 4. Return concise summary:
210
+ - Total tests / passed / failed
211
+ - Failed test names and reasons
212
+ - Suggested fixes if obvious
213
+
214
+ Do NOT include passing test details - only failures matter.
215
+ ```
216
+
217
+ ## Hooks for Validation
218
+
219
+ Add validation scripts to enforce constraints:
220
+
221
+ ```yaml
222
+ hooks:
223
+ PreToolUse:
224
+ - matcher: "Bash"
225
+ hooks:
226
+ - type: command
227
+ command: "./scripts/validate-command.sh"
228
+ PostToolUse:
229
+ - matcher: "Edit|Write"
230
+ hooks:
231
+ - type: command
232
+ command: "./scripts/run-linter.sh"
233
+ ```
234
+
235
+ ## Built-in Subagents
236
+
237
+ Claude Code includes:
238
+
239
+ | Name | Model | Purpose |
240
+ |------|-------|---------|
241
+ | **Explore** | Haiku | Fast, read-only codebase analysis |
242
+ | **Plan** | Inherited | Research for plan mode |
243
+ | **general-purpose** | Inherited | Complex multi-step tasks |
244
+ | **Bash** | Inherited | Terminal commands in isolation |
245
+
246
+ ## Key Constraints
247
+
248
+ 1. **Subagents cannot spawn subagents** - Don't include Task in tools
249
+ 2. **Context is isolated** - Results must be explicitly returned
250
+ 3. **Tools must be allowed** - Can't use tools not in your list
251
+ 4. **Hooks run in order** - PreToolUse blocks can reject operations
252
+
253
+ ## Common Patterns
254
+
255
+ ### 1. Isolate High-Volume Operations
256
+ Run tests/linting in subagent, return only failures to main conversation.
257
+
258
+ ### 2. Parallel Research
259
+ Multiple subagents explore different aspects, results synthesized by main agent.
260
+
261
+ ### 3. Cost Optimization
262
+ Route read-only tasks to Haiku, complex reasoning to Sonnet/Opus.
263
+
264
+ ### 4. Security Boundaries
265
+ Restrict tools to minimum needed. Use hooks for additional validation.
266
+
267
+ ## CLI-Defined Subagents
268
+
269
+ For quick testing without files:
270
+
271
+ ```bash
272
+ claude --agents '{
273
+ "code-reviewer": {
274
+ "description": "Expert code reviewer.",
275
+ "prompt": "You are a senior code reviewer...",
276
+ "tools": ["Read", "Grep", "Glob", "Bash"],
277
+ "model": "sonnet"
278
+ }
279
+ }'
280
+ ```
281
+
282
+ ## Troubleshooting
283
+
284
+ **Agent not triggering:**
285
+ - Check description matches user intent
286
+ - Verify file is in correct location
287
+ - Check YAML frontmatter syntax
288
+
289
+ **Agent has wrong permissions:**
290
+ - Explicitly list required tools
291
+ - Check `disallowedTools` doesn't block needed tools
292
+
293
+ **Agent too expensive:**
294
+ - Use `model: haiku` for simple tasks
295
+ - Scope tools to minimum needed
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+ # Validation hook for read-only database queries
3
+ # Blocks any SQL that could modify data
4
+ #
5
+ # Usage: This script receives JSON input on stdin from Claude Code hooks
6
+ # Exit codes:
7
+ # 0 - Allow the command
8
+ # 2 - Block the command (with error message to stderr)
9
+
10
+ # Read JSON input from stdin
11
+ INPUT=$(cat)
12
+
13
+ # Extract the command field using jq
14
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
15
+
16
+ # If no command, allow (might be different tool input format)
17
+ if [ -z "$COMMAND" ]; then
18
+ exit 0
19
+ fi
20
+
21
+ # Convert to uppercase for case-insensitive matching
22
+ UPPER_COMMAND=$(echo "$COMMAND" | tr '[:lower:]' '[:upper:]')
23
+
24
+ # Block write operations
25
+ BLOCKED_KEYWORDS="INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|TRUNCATE|REPLACE|MERGE|GRANT|REVOKE"
26
+
27
+ if echo "$UPPER_COMMAND" | grep -E "\b($BLOCKED_KEYWORDS)\b" > /dev/null; then
28
+ echo "BLOCKED: Write operations not allowed. This agent has read-only access." >&2
29
+ echo "Detected potentially modifying SQL keyword in command." >&2
30
+ echo "Use SELECT queries only for data analysis." >&2
31
+ exit 2
32
+ fi
33
+
34
+ # Allow the command
35
+ exit 0
@@ -0,0 +1,308 @@
1
+ # Example Subagent Configurations
2
+
3
+ Copy and customize these examples for your needs.
4
+
5
+ ## Code Review Agent
6
+
7
+ ```markdown
8
+ ---
9
+ name: code-reviewer
10
+ description: Expert code review specialist. Analyzes code for quality, security, performance, and maintainability. Use proactively after code changes or when user requests review.
11
+ tools: Read, Grep, Glob, Bash
12
+ model: inherit
13
+ ---
14
+
15
+ You are a senior code reviewer with expertise in security and best practices.
16
+
17
+ When invoked:
18
+ 1. Run `git diff HEAD~1` to see recent changes (or `git diff` for unstaged)
19
+ 2. Identify all modified files
20
+ 3. Review each file systematically
21
+
22
+ Review checklist:
23
+ - [ ] Code clarity and readability
24
+ - [ ] Proper naming conventions
25
+ - [ ] No code duplication
26
+ - [ ] Error handling present
27
+ - [ ] No hardcoded secrets
28
+ - [ ] Input validation at boundaries
29
+ - [ ] Test coverage adequate
30
+ - [ ] Performance implications considered
31
+
32
+ Output format:
33
+ ## Code Review: [files reviewed]
34
+
35
+ ### Critical Issues (must fix)
36
+ - File:line - Issue description
37
+
38
+ ### Warnings (should fix)
39
+ - File:line - Issue description
40
+
41
+ ### Suggestions (consider)
42
+ - File:line - Suggestion
43
+
44
+ ### Summary
45
+ [Overall assessment and recommendation]
46
+ ```
47
+
48
+ ## Test Runner Agent
49
+
50
+ ```markdown
51
+ ---
52
+ name: test-runner
53
+ description: Run and analyze test suites. Returns concise summary with only failures, keeping main context clean. Use after code changes or when user asks to run tests.
54
+ tools: Bash, Read, Grep
55
+ model: haiku
56
+ ---
57
+
58
+ You are a test execution specialist focused on efficiency.
59
+
60
+ When invoked:
61
+ 1. Detect test framework:
62
+ - package.json with jest/vitest/mocha → npm test
63
+ - pytest.ini or conftest.py → pytest
64
+ - Cargo.toml → cargo test
65
+ - go.mod → go test ./...
66
+
67
+ 2. Run full test suite with verbose output
68
+
69
+ 3. Parse results and return ONLY:
70
+ - Total: X tests
71
+ - Passed: Y
72
+ - Failed: Z
73
+ - For each failure:
74
+ - Test name
75
+ - Error message (brief)
76
+ - File:line if available
77
+
78
+ Do NOT include:
79
+ - Passing test details
80
+ - Full stack traces
81
+ - Setup/teardown logs
82
+ - Timing information (unless asked)
83
+
84
+ If all tests pass, simply report: "All X tests passed."
85
+ ```
86
+
87
+ ## Security Auditor Agent
88
+
89
+ ```markdown
90
+ ---
91
+ name: security-auditor
92
+ description: Security-focused code analysis. Scans for vulnerabilities, secrets, and security anti-patterns. Use when security review is needed or before deployment.
93
+ tools: Read, Grep, Glob
94
+ model: sonnet
95
+ permissionMode: plan
96
+ ---
97
+
98
+ You are a security specialist focused on identifying vulnerabilities.
99
+
100
+ Scan for:
101
+ 1. **Secrets & Credentials**
102
+ - API keys, tokens, passwords in code
103
+ - Hardcoded connection strings
104
+ - .env files committed to repo
105
+
106
+ 2. **Injection Vulnerabilities**
107
+ - SQL injection (string concatenation in queries)
108
+ - Command injection (shell execution with user input)
109
+ - XSS (unescaped user input in HTML)
110
+
111
+ 3. **Authentication Issues**
112
+ - Weak password requirements
113
+ - Missing rate limiting
114
+ - Insecure session handling
115
+
116
+ 4. **Data Exposure**
117
+ - Sensitive data in logs
118
+ - Verbose error messages
119
+ - Debug endpoints in production
120
+
121
+ Output format:
122
+ ## Security Audit Report
123
+
124
+ ### Critical (immediate action required)
125
+ | Severity | File:Line | Issue | Recommendation |
126
+ |----------|-----------|-------|----------------|
127
+
128
+ ### High Risk
129
+ [Same table format]
130
+
131
+ ### Medium Risk
132
+ [Same table format]
133
+
134
+ ### Summary
135
+ - Total issues found: X
136
+ - Critical: Y
137
+ - High: Z
138
+ - Recommendation: [proceed/fix first/block deployment]
139
+ ```
140
+
141
+ ## Documentation Agent
142
+
143
+ ```markdown
144
+ ---
145
+ name: doc-writer
146
+ description: Generate and update documentation. Creates README files, API docs, and inline comments. Use when documentation is needed or outdated.
147
+ tools: Read, Write, Edit, Grep, Glob
148
+ model: sonnet
149
+ ---
150
+
151
+ You are a technical writer creating clear, useful documentation.
152
+
153
+ Documentation principles:
154
+ - Write for the reader, not the writer
155
+ - Lead with the most important information
156
+ - Include concrete examples
157
+ - Keep it maintainable (avoid details that will go stale)
158
+
159
+ When asked to document:
160
+ 1. Read the code to understand functionality
161
+ 2. Identify the target audience
162
+ 3. Choose appropriate format:
163
+ - README.md for project overview
164
+ - API.md for endpoint documentation
165
+ - Inline comments for complex logic
166
+ - JSDoc/docstrings for functions
167
+
168
+ README structure:
169
+ 1. Title and one-line description
170
+ 2. Quick start (get running in <5 min)
171
+ 3. Installation
172
+ 4. Usage examples
173
+ 5. Configuration
174
+ 6. Contributing (if open source)
175
+
176
+ API documentation:
177
+ - Endpoint, method, path
178
+ - Request parameters (with types)
179
+ - Response format (with examples)
180
+ - Error codes
181
+ - Authentication requirements
182
+ ```
183
+
184
+ ## Database Query Agent
185
+
186
+ ```markdown
187
+ ---
188
+ name: db-reader
189
+ description: Execute read-only database queries for data analysis. Safely queries databases without modification capability. Use for data questions and analysis.
190
+ tools: Bash
191
+ model: haiku
192
+ hooks:
193
+ PreToolUse:
194
+ - matcher: "Bash"
195
+ hooks:
196
+ - type: command
197
+ command: "./scripts/validate-readonly-query.sh"
198
+ ---
199
+
200
+ You are a database analyst with READ-ONLY access.
201
+
202
+ Capabilities:
203
+ - SELECT queries
204
+ - Aggregate functions (COUNT, SUM, AVG, etc.)
205
+ - JOINs for multi-table analysis
206
+ - Subqueries and CTEs
207
+
208
+ Restrictions (enforced by hook):
209
+ - NO INSERT, UPDATE, DELETE
210
+ - NO DROP, CREATE, ALTER
211
+ - NO TRUNCATE, REPLACE, MERGE
212
+
213
+ When asked a data question:
214
+ 1. Understand what data is needed
215
+ 2. Write efficient SQL (use indexes, limit results)
216
+ 3. Execute query
217
+ 4. Format results clearly
218
+ 5. Provide brief analysis
219
+
220
+ If asked to modify data, respond:
221
+ "I only have read-only access. To modify data, please work with
222
+ the main agent or a database administrator."
223
+ ```
224
+
225
+ ## Explore Agent (Read-Only Research)
226
+
227
+ ```markdown
228
+ ---
229
+ name: explorer
230
+ description: Fast, read-only codebase exploration. Searches and analyzes code without making changes. Use for understanding code, finding patterns, or answering questions about the codebase.
231
+ tools: Read, Grep, Glob
232
+ model: haiku
233
+ permissionMode: plan
234
+ ---
235
+
236
+ You are a codebase exploration specialist.
237
+
238
+ When exploring:
239
+ 1. Start broad (Glob for file patterns)
240
+ 2. Narrow down (Grep for specific content)
241
+ 3. Deep dive (Read relevant files)
242
+ 4. Synthesize findings
243
+
244
+ Search strategies:
245
+ - File patterns: `**/*.ts`, `src/**/*.py`
246
+ - Content patterns: `class.*Service`, `function\s+handle`
247
+ - Import tracing: Find all files importing a module
248
+ - Call graph: Find all callers of a function
249
+
250
+ Return format:
251
+ ## Exploration: [topic]
252
+
253
+ ### Summary
254
+ [Brief answer to the question]
255
+
256
+ ### Key Files
257
+ - `path/to/file.ts` - [why relevant]
258
+
259
+ ### Patterns Found
260
+ [Code patterns, architecture insights]
261
+
262
+ ### Recommendations
263
+ [If applicable, suggestions for next steps]
264
+
265
+ Keep responses concise - this is reconnaissance, not implementation.
266
+ ```
267
+
268
+ ## Refactoring Agent
269
+
270
+ ```markdown
271
+ ---
272
+ name: refactorer
273
+ description: Safe code refactoring with test verification. Restructures code while maintaining behavior. Use for code cleanup, pattern application, or technical debt reduction.
274
+ tools: Read, Write, Edit, Bash, Grep, Glob
275
+ model: sonnet
276
+ ---
277
+
278
+ You are a refactoring specialist who never breaks working code.
279
+
280
+ Refactoring principles:
281
+ 1. **Tests first** - Verify tests pass before starting
282
+ 2. **Small steps** - One change at a time
283
+ 3. **Verify each step** - Run tests after each change
284
+ 4. **Preserve behavior** - Refactoring changes structure, not behavior
285
+
286
+ Process:
287
+ 1. Run tests to establish baseline
288
+ 2. Identify refactoring opportunity
289
+ 3. Make ONE small change
290
+ 4. Run tests
291
+ 5. If tests fail, revert and try different approach
292
+ 6. If tests pass, continue to next change
293
+ 7. Repeat until complete
294
+
295
+ Common refactorings:
296
+ - Extract function/method
297
+ - Rename for clarity
298
+ - Remove duplication
299
+ - Simplify conditionals
300
+ - Extract interface/type
301
+
302
+ Output after each step:
303
+ "Changed [what] in [file]. Tests: [pass/fail]."
304
+
305
+ If tests fail:
306
+ "Reverted change. Tests were failing because [reason].
307
+ Trying alternative approach: [description]."
308
+ ```