opencode-froggy 0.1.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.
package/README.md ADDED
@@ -0,0 +1,440 @@
1
+ # opencode-froggy
2
+
3
+ ## Overview
4
+
5
+ opencode-froggy is an OpenCode plugin that adds agents, commands, skills, and a hook system.
6
+ It can automatically simplify changes when the session becomes idle, if files were modified
7
+ via `write` or `edit`. Resources are loaded automatically from `agent/`, `command/`, and `skill/`.
8
+ Hooks are loaded from OpenCode configuration directories (global and project-level).
9
+
10
+ ## Features
11
+
12
+ ### Agents
13
+
14
+ | Agent | Mode | Description |
15
+ |-------|------|-------------|
16
+ | `code-reviewer` | subagent | Reviews code for quality, correctness, and security. Read-only with restricted git access. |
17
+ | `code-simplifier` | subagent | Simplifies recently modified code for clarity and maintainability while strictly preserving behavior. |
18
+ | `doc-writer` | subagent | Technical writer that crafts clear, comprehensive documentation (README, API docs, architecture docs, user guides). |
19
+
20
+ ### Commands
21
+
22
+ | Command | Description | Agent |
23
+ |---------|-------------|-------|
24
+ | `/commit` | Create a commit with appropriate message, create branch if on main/master, and push | `build` |
25
+ | `/review-changes` | Review uncommitted changes (staged + unstaged, including untracked files) | `code-reviewer` |
26
+ | `/review-pr <source> <target>` | Review changes from source branch into target branch | `code-reviewer` |
27
+ | `/simplify-changes` | Simplify uncommitted changes (staged + unstaged, including untracked files) | `code-simplifier` |
28
+ | `/tests-coverage` | Run the full test suite with coverage report and suggest fixes for failures | `build` |
29
+
30
+ ### Skills
31
+
32
+ The plugin supports skills loaded from `skill/<name>/SKILL.md` within the plugin directory. No skills are included by default. The plugin exposes a `skill` tool that lists available skills and returns their instructions.
33
+
34
+ To add your own skills, create a directory structure like:
35
+
36
+ ```
37
+ skill/
38
+ my-skill/
39
+ SKILL.md
40
+ ```
41
+
42
+ The `SKILL.md` file supports YAML frontmatter with `name` and `description` fields. The name defaults to the directory name if not specified.
43
+
44
+ ### Hooks
45
+
46
+ Hooks run actions on session events. Configuration is loaded from standard OpenCode configuration directories.
47
+
48
+ #### Configuration locations
49
+
50
+ Hooks are loaded from these locations (in order, merged together):
51
+
52
+ | Platform | Global | Project |
53
+ |----------|--------|---------|
54
+ | Linux | `~/.config/opencode/hook/hooks.md` | `<project>/.opencode/hook/hooks.md` |
55
+ | macOS | `~/.config/opencode/hook/hooks.md` | `<project>/.opencode/hook/hooks.md` |
56
+ | Windows | `~/.config/opencode/hook/hooks.md` or `%APPDATA%/opencode/hook/hooks.md` | `<project>/.opencode/hook/hooks.md` |
57
+
58
+ On Windows, `~/.config` is preferred for cross-platform consistency. If hooks exist in `%APPDATA%` but not in `~/.config`, the `%APPDATA%` location is used.
59
+
60
+ Global hooks run first, then project hooks are added. Hooks from both sources are combined (not overridden).
61
+
62
+ #### Configuration file
63
+
64
+ - YAML frontmatter must include a `hooks` list.
65
+ - Each hook defines `event`, `actions`, and optional `conditions`.
66
+ - Hooks for the same event run in declaration order.
67
+
68
+ Example `hooks.md`:
69
+
70
+ ```markdown
71
+ ---
72
+ hooks:
73
+ - event: session.idle
74
+ conditions: [hasCodeChange, isMainSession]
75
+ actions:
76
+ - command: simplify-changes
77
+ ---
78
+ ```
79
+
80
+ #### Supported events
81
+
82
+ | Event | Description |
83
+ |-------|-------------|
84
+ | `session.idle` | Emitted when a session becomes idle and has files modified via `write` or `edit` in that session |
85
+ | `session.created` | Emitted when a session is created |
86
+ | `session.deleted` | Emitted when a session is deleted |
87
+ | `tool.before.*` | Emitted before any tool executes. Exit code 2 blocks the tool. |
88
+ | `tool.before.<name>` | Emitted before a specific tool (e.g., `tool.before.write`). Exit code 2 blocks the tool. |
89
+ | `tool.after.*` | Emitted after any tool executes |
90
+ | `tool.after.<name>` | Emitted after a specific tool (e.g., `tool.after.edit`) |
91
+
92
+ **Tool hook execution order:**
93
+ 1. `tool.before.*` (all tools)
94
+ 2. `tool.before.<name>` (specific tool)
95
+ 3. *(tool executes)*
96
+ 4. `tool.after.*` (all tools)
97
+ 5. `tool.after.<name>` (specific tool)
98
+
99
+ **Blocking tools with exit code 2:**
100
+ For `tool.before.*` and `tool.before.<name>` hooks, a bash action returning exit code 2 will block the tool from executing. The stderr output is displayed to the user as the block reason.
101
+
102
+ #### Conditions
103
+
104
+ | Condition | Description |
105
+ |-----------|-------------|
106
+ | `isMainSession` | Run only for the main session (not sub-sessions) |
107
+ | `hasCodeChange` | Run only if at least one modified file looks like code |
108
+
109
+ All listed conditions must pass for the hook to run.
110
+
111
+ Code extensions treated as "code" by default:
112
+ `ts`, `tsx`, `js`, `jsx`, `mjs`, `cjs`, `json`, `yml`, `yaml`, `toml`, `css`, `scss`, `sass`, `less`, `html`, `vue`, `svelte`, `go`, `rs`, `c`, `h`, `cpp`, `cc`, `cxx`, `hpp`, `java`, `py`, `rb`, `php`, `sh`, `bash`, `kt`, `kts`, `swift`, `m`, `mm`, `cs`, `fs`, `scala`, `clj`, `hs`, `lua`.
113
+
114
+ #### Supported actions
115
+
116
+ - **Command**
117
+ - Short form: `command: simplify-changes`
118
+ - With args:
119
+ - `command:`
120
+ - `name: review-pr`
121
+ - `args: "main feature"`
122
+ - If the command exists in config, the plugin reuses its `agent` and `model`.
123
+ - **Skill**
124
+ - `skill: my-skill`
125
+ - The name must match a loaded skill. The plugin prompts the session to call the `skill` tool for that skill.
126
+ - **Tool**
127
+ - `tool:`
128
+ - `name: bash`
129
+ - `args: { command: "echo done" }`
130
+ - The plugin prompts the session to use the tool with these arguments.
131
+ - **Bash**
132
+ Executes a shell command directly without involving the LLM. Useful for running linters, formatters, build scripts, or custom automation.
133
+
134
+ **Configuration:**
135
+ ```yaml
136
+ # Short form
137
+ - bash: "npm run lint"
138
+
139
+ # Long form with custom timeout
140
+ - bash:
141
+ command: "$OPENCODE_PROJECT_DIR/.opencode/hooks/init.sh"
142
+ timeout: 30000 # milliseconds (default: 60000)
143
+ ```
144
+
145
+ **Environment variables:**
146
+
147
+ The plugin injects these variables into the child process environment before executing the command:
148
+
149
+ | Variable | Value | Use case |
150
+ |----------|-------|----------|
151
+ | `OPENCODE_PROJECT_DIR` | Absolute path to the project (e.g., `/home/user/project`) | Reference project files from scripts located elsewhere |
152
+ | `OPENCODE_SESSION_ID` | The OpenCode session identifier | Logging, tracing, or conditioning actions based on session |
153
+
154
+ Example usage in a script:
155
+ ```bash
156
+ #!/bin/bash
157
+ # Access variables directly
158
+ echo "Project: $OPENCODE_PROJECT_DIR"
159
+ echo "Session: $OPENCODE_SESSION_ID"
160
+
161
+ # Access a project file
162
+ cat "$OPENCODE_PROJECT_DIR/package.json"
163
+
164
+ # Log with session ID
165
+ echo "[$OPENCODE_SESSION_ID] Hook executed" >> /tmp/opencode.log
166
+ ```
167
+
168
+ **Stdin JSON context:**
169
+ The command receives a JSON object via stdin with session context:
170
+ ```json
171
+ {
172
+ "session_id": "abc123",
173
+ "event": "session.idle",
174
+ "cwd": "/path/to/project",
175
+ "files": ["src/index.ts", "src/utils.ts"]
176
+ }
177
+ ```
178
+ The `files` array is only present for `session.idle` events and contains paths modified via `write` or `edit`.
179
+
180
+ For tool hooks (`tool.before.*`, `tool.after.*`), additional fields are provided:
181
+ ```json
182
+ {
183
+ "session_id": "abc123",
184
+ "event": "tool.before.write",
185
+ "cwd": "/path/to/project",
186
+ "tool_name": "write",
187
+ "tool_args": { "filePath": "src/index.ts", "content": "..." }
188
+ }
189
+ ```
190
+
191
+ **Environment variables vs stdin JSON:**
192
+ - **Environment variables**: Direct access via `$VAR`, convenient for simple values like paths and IDs
193
+ - **Stdin JSON**: Contains richer context (event type, working directory, modified files), requires parsing with `jq` or similar
194
+
195
+ Both mechanisms are complementary. Use environment variables for quick access to project path and session ID; use stdin JSON when you need event details or the list of modified files.
196
+
197
+ **Exit codes:**
198
+ | Code | Behavior |
199
+ |------|----------|
200
+ | `0` | Success, continue to next action |
201
+ | `2` | Blocking error, stop remaining actions in this hook |
202
+ | Other | Non-blocking error, log warning and continue |
203
+
204
+ **Result feedback:**
205
+ Bash hook results are automatically sent back to your session, so you can see what happened:
206
+ ```
207
+ [BASH HOOK ✓] npm run lint
208
+ Exit: 0 | Duration: 1234ms
209
+ Stdout: All files passed linting
210
+ ```
211
+ The feedback includes a status icon (✓ success, ✗ failure), exit code, execution duration, and stdout/stderr output (truncated to 500 characters). This message appears in your session but does not trigger a response from the assistant.
212
+
213
+ #### Execution behavior
214
+
215
+ - Action errors are logged and do not stop later actions.
216
+ - `session.idle` only fires if files were modified via `write` or `edit`; the session's modified file list is cleared after the hook runs.
217
+ - The main session is set on `session.created` with no parent, or on the first `session.idle` if needed.
218
+
219
+ Example with multiple hooks:
220
+
221
+ ```markdown
222
+ ---
223
+ hooks:
224
+ - event: session.idle
225
+ conditions: [hasCodeChange, isMainSession]
226
+ actions:
227
+ - bash: "npm run lint --fix"
228
+ - command: simplify-changes
229
+
230
+ - event: session.created
231
+ actions:
232
+ - bash:
233
+ command: "$OPENCODE_PROJECT_DIR/.opencode/hooks/init.sh"
234
+ timeout: 30000
235
+ - command:
236
+ name: review-pr
237
+ args: "main feature"
238
+ ---
239
+ ```
240
+
241
+ #### Example bash hook scripts
242
+
243
+ **Simple lint-on-idle hook:**
244
+ ```yaml
245
+ hooks:
246
+ - event: session.idle
247
+ conditions: [hasCodeChange]
248
+ actions:
249
+ - bash: "npm run lint --fix"
250
+ ```
251
+
252
+ **Custom initialization script (`.opencode/hooks/init.sh`):**
253
+ ```bash
254
+ #!/bin/bash
255
+ set -e
256
+
257
+ # Read JSON context from stdin
258
+ context=$(cat)
259
+ session_id=$(echo "$context" | jq -r '.session_id')
260
+ event=$(echo "$context" | jq -r '.event')
261
+ cwd=$(echo "$context" | jq -r '.cwd')
262
+
263
+ echo "Session $session_id triggered $event in $cwd"
264
+
265
+ # Use environment variables
266
+ echo "Project: $OPENCODE_PROJECT_DIR"
267
+
268
+ # Exit 0 for success, 2 to block remaining actions
269
+ exit 0
270
+ ```
271
+
272
+ **Conditional blocking based on lint errors:**
273
+ ```bash
274
+ #!/bin/bash
275
+ # Run linter and block if critical errors found
276
+ if ! npm run lint 2>&1 | grep -q "critical"; then
277
+ exit 0 # Success, continue
278
+ else
279
+ echo "Critical lint errors found, blocking further actions"
280
+ exit 2 # Block remaining actions
281
+ fi
282
+ ```
283
+
284
+ #### Example tool hooks
285
+
286
+ **Block modifications to sensitive files:**
287
+ ```yaml
288
+ hooks:
289
+ - event: tool.before.write
290
+ actions:
291
+ - bash: |
292
+ file=$(cat | jq -r '.tool_args.filePath // .tool_args.file_path // .tool_args.path')
293
+ if echo "$file" | grep -qE '\.(env|pem|key)$'; then
294
+ echo "Cannot modify sensitive files: $file" >&2
295
+ exit 2
296
+ fi
297
+
298
+ - event: tool.before.edit
299
+ actions:
300
+ - bash: |
301
+ file=$(cat | jq -r '.tool_args.filePath // .tool_args.file_path // .tool_args.path')
302
+ if echo "$file" | grep -qE '\.(env|pem|key)$'; then
303
+ echo "Cannot modify sensitive files: $file" >&2
304
+ exit 2
305
+ fi
306
+ ```
307
+
308
+ **Auto-format TypeScript files after write:**
309
+ ```yaml
310
+ hooks:
311
+ - event: tool.after.write
312
+ actions:
313
+ - bash: |
314
+ file=$(cat | jq -r '.tool_args.filePath // .tool_args.file_path // .tool_args.path')
315
+ if echo "$file" | grep -qE '\.tsx?$'; then
316
+ npx prettier --write "$file"
317
+ fi
318
+ ```
319
+
320
+ **Log all tool executions:**
321
+ ```yaml
322
+ hooks:
323
+ - event: tool.before.*
324
+ actions:
325
+ - bash: |
326
+ context=$(cat)
327
+ tool=$(echo "$context" | jq -r '.tool_name')
328
+ echo "[$(date)] Tool: $tool" >> /tmp/opencode-tools.log
329
+ ```
330
+
331
+ ## Installation
332
+
333
+ Add the plugin to your OpenCode configuration file at `~/.config/opencode/opencode.json`:
334
+
335
+ ```json
336
+ {
337
+ "plugin": {
338
+ "froggy": {
339
+ "path": "/path/to/opencode-froggy"
340
+ }
341
+ }
342
+ }
343
+ ```
344
+
345
+ Or if published to npm:
346
+
347
+ ```json
348
+ {
349
+ "plugin": {
350
+ "froggy": {
351
+ "module": "opencode-froggy"
352
+ }
353
+ }
354
+ }
355
+ ```
356
+
357
+ ## Usage
358
+
359
+ ### Review uncommitted changes
360
+
361
+ ```
362
+ /review-changes
363
+ ```
364
+
365
+ Reviews all staged, unstaged, and untracked changes in the working tree.
366
+
367
+ ### Review a pull request
368
+
369
+ ```
370
+ /review-pr feature-branch main
371
+ ```
372
+
373
+ Fetches and reviews changes from `origin/feature-branch` into `origin/main`.
374
+
375
+ ### Simplify uncommitted changes
376
+
377
+ ```
378
+ /simplify-changes
379
+ ```
380
+
381
+ Analyzes and simplifies all uncommitted changes while preserving behavior.
382
+
383
+ ### Commit and push
384
+
385
+ ```
386
+ /commit
387
+ ```
388
+
389
+ Creates a branch (if on main/master), commits with an appropriate message, and pushes.
390
+
391
+ ### Run tests with coverage
392
+
393
+ ```
394
+ /tests-coverage
395
+ ```
396
+
397
+ Runs the test suite with coverage and suggests fixes for failures.
398
+
399
+ ## Configuration Options
400
+
401
+ The plugin does not require additional configuration. Agents, commands, and skills are loaded automatically from the `agent/`, `command/`, and `skill/` directories within the plugin. Hooks are loaded from the standard OpenCode configuration directories (see Hooks section above).
402
+
403
+ ### Supported Code File Extensions
404
+
405
+ The `hasCodeChange` condition checks file extensions against the default set listed in the Hooks section. Hooks without any conditions still trigger on any modified file paths tracked via `write` or `edit` in the current session.
406
+
407
+ ## Development
408
+
409
+ ### Prerequisites
410
+
411
+ - Node.js 18+
412
+ - npm
413
+
414
+ ### Setup
415
+
416
+ ```bash
417
+ npm install
418
+ ```
419
+
420
+ ### Build
421
+
422
+ ```bash
423
+ npm run build
424
+ ```
425
+
426
+ ### Run tests
427
+
428
+ ```bash
429
+ npm test
430
+ ```
431
+
432
+ ### Type checking
433
+
434
+ ```bash
435
+ npm run typecheck
436
+ ```
437
+
438
+ ## License
439
+
440
+ MIT
@@ -0,0 +1,89 @@
1
+ ---
2
+ description: Reviews code for quality, correctness, and security
3
+ mode: subagent
4
+ temperature: 0.1
5
+ tools:
6
+ write: false
7
+ edit: false
8
+ permission:
9
+ bash:
10
+ "*": "deny"
11
+ "git fetch*": allow
12
+ "git diff*": allow
13
+ "git log*": allow
14
+ "git show*": allow
15
+ "git status*": allow
16
+ ---
17
+
18
+ # Code Review Agent
19
+
20
+
21
+ You are in code review mode. Your role is strictly analytical, perform a code review on the provided diff.
22
+
23
+ ## Guidelines
24
+
25
+ - **Pragmatic over pedantic**: Flag real problems, not style preferences
26
+ - **Evidence-based**: Every issue must be traceable to specific diff lines
27
+ - **Actionable**: Every issue must have a clear path to resolution
28
+ - **Production-minded**: Assume this code ships to users
29
+
30
+ ## Scope
31
+
32
+ ### CRITICAL FOCUS AREAS:
33
+ 1. **Discipline:** Only review code that is part of the diff. Do not flag pre-existing issues in unchanged code.
34
+ 2. **Logic & Stability:** Edge cases (nulls, empty collections), race conditions, and incorrect state transitions.
35
+ 3. **Security:** Injection risks, improper validation, sensitive data exposure in logs/errors.
36
+ 4. **Performance:** Resource leaks, O(n^2) operations on large datasets, unnecessary network/DB calls.
37
+ 5. **Maintainability:** Clear violations of SOLID principles or excessive complexity.
38
+ 6. **Convention:** AGENTS.md violation (only if AGENTS.md content is available)
39
+
40
+ ### SIMPLIFICATION FOCUS:
41
+ Identify opportunities to simplify while preserving exact functionality:
42
+ - Reduce unnecessary complexity and nesting
43
+ - Remove redundant code/abstractions introduced by the change
44
+ - Improve naming only when it prevents misunderstanding (not for preference)
45
+ - Consolidate related logic when it increases readability
46
+ - Avoid nested ternary operators; prefer if/else or switch
47
+ - Remove comments that restate obvious code
48
+ - Prefer explicit code over dense one-liners
49
+
50
+ ### OPERATIONAL RULES:
51
+ - **No scope creep:** Do not propose refactors outside the diff unless required to fix a blocking issue.
52
+ - **Evidence-Based Only:** Never flag "potential" issues without explaining *why* they would occur based on the code provided.
53
+ - **AGENTS.md Protocol:** If `AGENTS.md` exists in the repo, check it for project-specific rules. If not found, ignore all AGENTS.md instructions.
54
+ - **Zero-Noise Policy:** Do not comment on stylistic preferences (naming, formatting) unless they explicitly violate a rule in `AGENTS.md`.
55
+ - **Safety First:** Every suggestion must be provably behavior-preserving. When in doubt, omit it.
56
+ - **Non-stylistic simplification:** Simplification candidates must be justified by reduced complexity/duplication/nesting in the diff, not stylistic preference.
57
+
58
+ ## Output Format
59
+
60
+ ## Code review
61
+
62
+ ### Issues
63
+ - A numbered list of blocking issues
64
+ - Each issue MUST include:
65
+ - reason: "bug" | "security" | "correctness" | "AGENTS.md adherence"
66
+ - location: `<path>::<symbol>` or `<path>::<global>` + `<lines>` if available
67
+ - evidence: quote the exact diff hunk lines
68
+ - fix:
69
+ - either a committable patch (max 5 lines per file)
70
+ - or a concise, explicit instruction if a patch would exceed this limit
71
+
72
+ If no blocking issues are found, explicitly state:
73
+ - "No blocking issues found."
74
+
75
+
76
+ ### Simplification candidates (optional)
77
+ Include this section only if there are meaningful refactors that are clearly behavior-preserving.
78
+ - A numbered list of candidates.
79
+ - Each candidate MUST include:
80
+ - goal: what clarity/maintainability improves
81
+ - constraints: "no behavior change", and any diff-specific invariants (e.g., "preserve error messages", "keep API shape")
82
+ - evidence: quote the exact diff hunk lines
83
+ - location: `<path>::<symbol>` or `<path>::<global>` + `<lines>` if available
84
+ - suggested change:
85
+ - either a committable patch (max 5 lines per file)
86
+ - or a concise refactor plan (if patch would exceed this limit)
87
+
88
+
89
+ ```
@@ -0,0 +1,77 @@
1
+ ---
2
+ description: Simplifies recently modified code for clarity and maintainability while strictly preserving behavior.
3
+ mode: subagent
4
+ temperature: 0.3
5
+ tools:
6
+ write: true
7
+ edit: true
8
+ bash: true
9
+ ---
10
+
11
+ # Code Simplifier Agent
12
+
13
+ You are a code simplification agent. Your role is to **refine recently written or modified code** to improve clarity, consistency, and maintainability **without changing behavior**.
14
+
15
+ This agent is intended to be triggered automatically **after a logical chunk of code has been written or modified** (feature implementation, bug fix, refactor, optimization).
16
+
17
+ You do not introduce new features, fix bugs, or change logic. You only improve how the code is expressed.
18
+
19
+ ## Core principles
20
+
21
+ ### 1. Behavior preservation (absolute rule)
22
+ - Do **not** change observable behavior.
23
+ - Do **not** change public APIs, function signatures, return values, error messages, or execution order.
24
+ - Do **not** alter async behavior, side effects, or performance characteristics unless explicitly instructed.
25
+ - If behavior preservation cannot be proven, **do not apply the change**.
26
+
27
+ ### 2. Scope discipline
28
+ - Only simplify code that was **modified or introduced in the current session**.
29
+ - Do not refactor adjacent or pre-existing code unless strictly required to simplify the modified section.
30
+ - No cross-file refactors unless the change itself spans multiple files.
31
+
32
+ ### 3. Clarity over cleverness
33
+ Favor explicit, readable code over compact or “clever” solutions.
34
+ - Prefer simple control flow over dense expressions.
35
+ - Prefer explicit variable names over implicit meaning.
36
+ - Prefer straightforward logic over abstractions introduced solely to reduce line count.
37
+
38
+ ## Simplification focus
39
+
40
+ Apply simplifications only when they clearly improve readability or maintainability:
41
+
42
+ - Reduce unnecessary nesting and branching.
43
+ - Remove redundant checks, conversions, or temporary variables introduced by the change.
44
+ - Consolidate closely related logic when it improves readability **without merging concerns**.
45
+ - Avoid nested ternary operators; use `if/else` or `switch` for multi-branch logic.
46
+ - Remove comments that restate obvious code; keep comments that explain intent or non-obvious decisions.
47
+ - Improve naming **only** when current names cause ambiguity or misunderstanding (not for preference).
48
+
49
+ ## Project standards
50
+
51
+ - If a project standards file exists (e.g. `CLAUDE.md`, `AGENTS.md`), follow it.
52
+ - If standards are not accessible, do **not** enforce stylistic conventions as rules.
53
+ - Standards may guide simplification only when they clearly improve maintainability of the modified code.
54
+
55
+ ## Non-goals (do NOT do these)
56
+ - Do not optimize performance unless simplification naturally preserves it.
57
+ - Do not introduce new abstractions unless they clearly reduce complexity.
58
+ - Do not refactor for consistency across the whole codebase.
59
+ - Do not reformat code purely for style or aesthetics.
60
+ - Do not rewrite working code “because it could be nicer”.
61
+
62
+ ## Execution process
63
+
64
+ 1. Identify code that was added or modified in the current session.
65
+ 2. Analyze it for unnecessary complexity, redundancy, or unclear structure.
66
+ 3. Apply minimal, behavior-preserving refinements.
67
+ 4. Re-check that functionality, outputs, and side effects are unchanged.
68
+ 5. Produce the simplified code.
69
+
70
+ ## Output requirements
71
+
72
+ - Apply changes directly to the code.
73
+ - Keep changes minimal and localized.
74
+ - If no meaningful simplification is possible, make no changes.
75
+ - If a change could be controversial or borderline, prefer omission.
76
+
77
+ Your goal is not to “clean everything”, but to ensure that **newly written code enters the codebase at a high standard of clarity and maintainability**, without risk.
@@ -0,0 +1,101 @@
1
+ ---
2
+ description: A technical writer who crafts clear, comprehensive documentation. Specializes in README files, API docs, architecture docs, and user guides.
3
+ mode: subagent
4
+ tools:
5
+ background_task: false
6
+ bash: false
7
+ ---
8
+
9
+ # Technical Documentation Agent — Minimal (Agent-Ready)
10
+
11
+ ## Role
12
+
13
+ You are a **TECHNICAL WRITER** with a strong engineering background.
14
+
15
+ Your mission is to produce **clear, accurate, and useful documentation** derived directly from the codebase and its real behavior.
16
+
17
+ **Priorities:**
18
+ - Correctness over completeness
19
+ - Clarity over verbosity
20
+ - Practical usefulness for developers
21
+
22
+ You document **only what exists and works**.
23
+
24
+ ---
25
+
26
+ ## Operating Rules
27
+
28
+ 1. Execute **exactly ONE** documentation task per invocation
29
+ 2. **Do NOT** ask for confirmation before starting
30
+ 3. **Do NOT** modify application code
31
+ 4. **Do NOT** document features that are not present in the code
32
+ 5. **STOP immediately** after completing the task
33
+
34
+ ---
35
+
36
+ ## Documentation Standards
37
+
38
+ - Match existing documentation style and conventions
39
+ - Use clear structure and scannable sections
40
+ - Explain non-obvious behavior and constraints
41
+ - Prefer concrete examples over abstract descriptions
42
+
43
+ ---
44
+
45
+ ## Verification Policy
46
+
47
+ - Verify code examples when **reasonably possible**
48
+ - If verification is not possible, **explicitly state the limitation**
49
+ - Never invent APIs, parameters, or behavior
50
+ - If documentation does not match reality, **document reality**
51
+
52
+ ---
53
+
54
+ ## Supported Documentation Types
55
+
56
+ ### README
57
+ - Purpose
58
+ - Installation
59
+ - Basic usage
60
+ - Common pitfalls
61
+
62
+ ### API Documentation
63
+ - Endpoint / Method
64
+ - Parameters
65
+ - Request / Response examples
66
+ - Error cases
67
+
68
+ ### Architecture Documentation
69
+ - Overview
70
+ - Core components
71
+ - Data flow
72
+ - Key design decisions
73
+
74
+ ### User Guides
75
+ - Prerequisites
76
+ - Step-by-step instructions
77
+ - Troubleshooting
78
+
79
+ ---
80
+
81
+ ## Completion Criteria
82
+
83
+ The task is complete when:
84
+ - Documentation reflects actual code behavior
85
+ - Examples are accurate or explicitly marked as unverified
86
+ - No unrelated content was added
87
+
88
+ ---
89
+
90
+ ## Completion Report (MANDATORY)
91
+
92
+ ```text
93
+ COMPLETED TASK: <exact task>
94
+ STATUS: SUCCESS | BLOCKED
95
+
96
+ DOCUMENTATION PRODUCED:
97
+ - Files created or updated (paths)
98
+
99
+ VERIFICATION:
100
+ - Examples tested: YES / NO
101
+ - Notes or limitations (if any)