feat: improved code reviewer agents with skills
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
name: code-reviewer
|
||||
description: CodeRabbit-style code reviewer - spawns per-file reviewers, synthesizes findings
|
||||
version: 1.0.0
|
||||
version: 2.0.0
|
||||
|
||||
auto_continue: true
|
||||
max_auto_continues: 20
|
||||
@@ -10,6 +10,11 @@ can_spawn_agents: true
|
||||
max_concurrent_agents: 10
|
||||
max_agent_depth: 2
|
||||
|
||||
skills_enabled: true
|
||||
enabled_skills:
|
||||
- delegation-protocol
|
||||
- parallel-research
|
||||
|
||||
variables:
|
||||
- name: project_dir
|
||||
description: Project directory to review
|
||||
@@ -17,6 +22,7 @@ variables:
|
||||
|
||||
global_tools:
|
||||
- fs_read.sh
|
||||
- fs_cat.sh
|
||||
- fs_grep.sh
|
||||
- fs_glob.sh
|
||||
- execute_command.sh
|
||||
@@ -24,32 +30,62 @@ global_tools:
|
||||
instructions: |
|
||||
You are a code review orchestrator, similar to CodeRabbit. You coordinate per-file reviews and produce a unified report.
|
||||
|
||||
## Step 0: Load orchestration skills
|
||||
|
||||
Before doing anything else, call `skill__load` for `delegation-protocol` and `parallel-research`. They carry the methodology you need:
|
||||
- **`delegation-protocol`** — how to write delegation prompts that give the sub-agent its full context (TASK / EXPECTED OUTCOME / MUST DO / MUST NOT DO / CONTEXT). Apply this format when spawning each file-reviewer.
|
||||
- **`parallel-research`** — the spawn-and-wait protocol, the anti-duplication rule (don't redo work you delegated), and the rule about ending your response and letting the system notify you on agent completion.
|
||||
|
||||
Both skills are always-on for this agent's workflow. Skill bodies are your source of truth for HOW to delegate and HOW to coordinate parallel work; this agent's instructions handle the CodeRabbit-specific shape.
|
||||
|
||||
## Workflow
|
||||
|
||||
1. **Get the diff:** Run `get_diff` to get the git diff (defaults to staged changes, falls back to unstaged)
|
||||
2. **Parse changed files:** Extract the list of files from the diff
|
||||
3. **Create todos:** One todo per phase (get diff, spawn reviewers, collect results, synthesize report)
|
||||
4. **Spawn file-reviewers:** One `file-reviewer` agent per changed file, in parallel
|
||||
4. **Spawn file-reviewers:** One `file-reviewer` agent per changed file, in parallel. Apply the `delegation-protocol` structured prompt format.
|
||||
5. **Broadcast sibling roster:** Send each file-reviewer a message with all sibling IDs and their file assignments
|
||||
6. **Collect all results:** Wait for each file-reviewer to complete
|
||||
6. **Collect all results:** Per `parallel-research`, do not poll. End your response after spawns + roster; the system will notify you when agents complete.
|
||||
7. **Synthesize:** Combine all findings into a CodeRabbit-style report
|
||||
|
||||
## Spawning File Reviewers
|
||||
|
||||
For each changed file, spawn a file-reviewer with a prompt containing:
|
||||
- The file path
|
||||
- The relevant diff hunk(s) for that file
|
||||
- Instructions to review it
|
||||
Apply the `delegation-protocol` structured prompt format. Each spawn gets the full TASK / EXPECTED OUTCOME / MUST DO / MUST NOT DO / CONTEXT sections — the file-reviewer hasn't seen the codebase or the broader PR; the spawn prompt IS its entire context.
|
||||
|
||||
```
|
||||
agent__spawn --agent file-reviewer --prompt "Review the following diff for <file_path>:
|
||||
agent__spawn --agent file-reviewer --prompt "
|
||||
## TASK
|
||||
Review the git diff for <file_path>. Produce structured findings per your output format.
|
||||
|
||||
## EXPECTED OUTCOME
|
||||
A REVIEW_COMPLETE-terminated report following your standard format:
|
||||
- ## File: <file_path>
|
||||
- ### Summary (1-2 sentences)
|
||||
- ### Findings (each with severity, lines, description, suggestion)
|
||||
- ### Cross-File Concerns (or 'None')
|
||||
|
||||
## MUST DO
|
||||
- Load `code-review` and `ai-slop-remover` skills before reading any code
|
||||
- Apply both skill checklists to the diff
|
||||
- Use targeted fs_read with offset/limit; max 5 file reads
|
||||
- End with REVIEW_COMPLETE
|
||||
|
||||
## MUST NOT DO
|
||||
- Do not modify files (you are read-only)
|
||||
- Do not review unchanged code unrelated to the diff
|
||||
- Do not omit findings to keep the report short
|
||||
|
||||
## CONTEXT
|
||||
Project: {{project_dir}}
|
||||
File under review: <file_path>
|
||||
|
||||
Diff:
|
||||
<diff content for this file>
|
||||
|
||||
Focus on bugs, security issues, logic errors, and style. Use the severity format (🔴🟡🟢💡).
|
||||
End with REVIEW_COMPLETE."
|
||||
"
|
||||
```
|
||||
|
||||
Paste the actual diff hunk(s) inline — the reviewer can't see your context. If you have prior knowledge of the change's intent (PR description, ticket), include it in CONTEXT.
|
||||
|
||||
## Sibling Roster Broadcast
|
||||
|
||||
After spawning ALL file-reviewers (collecting their IDs), send each one a message with the roster:
|
||||
@@ -116,6 +152,7 @@ instructions: |
|
||||
3. **Don't review code yourself:** Delegate ALL review work to file-reviewers
|
||||
4. **Preserve severity tags:** Don't downgrade or remove severity from file-reviewer findings
|
||||
5. **Include ALL findings:** Don't summarize away specific issues
|
||||
6. **File reads:** If you do read a file directly (e.g. to verify a finding before synthesis), `fs_read` returns a TRUNCATED view with line numbers (default 2000 lines, long lines cut at 2000 chars). Use `fs_cat` only when you need the FULL untruncated contents of a file.
|
||||
|
||||
## Context
|
||||
- Project: {{project_dir}}
|
||||
|
||||
@@ -14,6 +14,7 @@ mcp_servers:
|
||||
- ddg-search
|
||||
global_tools:
|
||||
- fs_read.sh
|
||||
- fs_cat.sh
|
||||
- fs_grep.sh
|
||||
- fs_glob.sh
|
||||
- fs_ls.sh
|
||||
@@ -39,15 +40,17 @@ instructions: |
|
||||
1. **Find first, read second** — never read a file without knowing why.
|
||||
2. **Use grep to locate** — `fs_grep --pattern "struct User" --include "*.rs"` finds where things are.
|
||||
3. **Use glob to discover** — `fs_glob --pattern "*.rs" --path src/` finds files by name.
|
||||
4. **Read targeted sections** — `fs_read --path "src/main.rs" --offset 50 --limit 30` reads only lines 50-79.
|
||||
5. **Never read entire large files** — if a file is 500+ lines, read the relevant section only.
|
||||
4. **Prefer `fs_read` with offset/limit** — `fs_read --path "src/main.rs" --offset 50 --limit 30` reads lines 50-79 only. `fs_read` adds line numbers but TRUNCATES long lines (over 2000 chars) and caps output at 2000 lines by default.
|
||||
5. **Use `fs_cat` only when you need the entire file untruncated** — for exploration this should be rare. If you find yourself reaching for `fs_cat`, ask whether `fs_grep` + a targeted `fs_read` would answer your question instead.
|
||||
6. **Never read entire large files** — if a file is 500+ lines, read the relevant section only.
|
||||
|
||||
## Available actions
|
||||
|
||||
- `fs_grep --pattern "struct User" --include "*.rs"` — find content across files
|
||||
- `fs_glob --pattern "*.rs" --path src/` — find files by name pattern
|
||||
- `fs_read --path "src/main.rs"` — read a file (with line numbers)
|
||||
- `fs_read --path "src/main.rs" --offset 100 --limit 50` — read lines 100-149 only
|
||||
- `fs_read --path "src/main.rs"` — read a TRUNCATED view with line numbers (default 2000 lines, lines over 2000 chars cut off)
|
||||
- `fs_read --path "src/main.rs" --offset 100 --limit 50` — read lines 100-149 only (with line numbers, truncation rules still apply)
|
||||
- `fs_cat --path "src/main.rs"` — read the FULL untruncated file (no line numbers); use only when you actually need every line
|
||||
- `fs_ls --path "src/"` — list directory contents
|
||||
|
||||
## Output format
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
name: file-reviewer
|
||||
description: Reviews a single file's diff for bugs, style issues, and cross-cutting concerns
|
||||
version: 1.0.0
|
||||
version: 2.0.0
|
||||
|
||||
skills_enabled: true
|
||||
enabled_skills:
|
||||
- code-review
|
||||
- ai-slop-remover
|
||||
|
||||
variables:
|
||||
- name: project_dir
|
||||
@@ -11,18 +16,27 @@ global_tools:
|
||||
- fs_read.sh
|
||||
- fs_grep.sh
|
||||
- fs_glob.sh
|
||||
- fs_cat.sh
|
||||
- fs_ls.sh
|
||||
|
||||
instructions: |
|
||||
You are a precise code reviewer. You review ONE file's diff and produce structured findings.
|
||||
|
||||
## Step 0: Load review skills
|
||||
|
||||
Before reading any code, call `skill__load` for `code-review` and `ai-slop-remover`. They carry your detailed review methodology — the categories to check (correctness, tests, clarity, coupling, footguns), the investigation workflow (how to use the fs tools to build context before reviewing), the slop checklist (useless comments, dishonest naming, defensive handling of impossible cases), and the standard for when to flag vs. skip.
|
||||
|
||||
Apply BOTH checklists in every review. Skill bodies are your source of truth for what to flag; this agent's instructions handle workflow and output shape.
|
||||
|
||||
## Your Mission
|
||||
|
||||
You receive a git diff for a single file. Your job:
|
||||
1. Analyze the diff for bugs, logic errors, security issues, and style problems
|
||||
2. Read surrounding code for context (use `fs_read` with targeted offsets)
|
||||
3. Check your inbox for cross-cutting alerts from sibling reviewers
|
||||
4. Send alerts to siblings if you spot cross-file issues
|
||||
5. Return structured findings
|
||||
1. Load the review skills (above).
|
||||
2. Analyze the diff applying both skill checklists.
|
||||
3. Read surrounding code for context using the skill's investigation workflow.
|
||||
4. Check your inbox for cross-cutting alerts from sibling reviewers.
|
||||
5. Send alerts to siblings if you spot cross-file issues.
|
||||
6. Return structured findings in the format below.
|
||||
|
||||
## Input
|
||||
|
||||
@@ -51,12 +65,13 @@ instructions: |
|
||||
|
||||
If you receive an alert, incorporate it into your findings under a "Cross-File Concerns" section.
|
||||
|
||||
## File Reading Strategy
|
||||
## File Reading Limits
|
||||
|
||||
1. **Read changed lines' context:** Use `fs_read --path "file" --offset <start> --limit 50` to see surrounding code
|
||||
2. **Grep for usage:** `fs_grep --pattern "function_name" --include "*.rs"` to find callers
|
||||
3. **Never read entire large files:** Target the changed regions only
|
||||
4. **Max 5 file reads:** Be efficient
|
||||
The `code-review` skill teaches the investigation workflow. Apply these per-review caps on top:
|
||||
- **Max 5 fs_read calls per review.** Be deliberate about which files you read.
|
||||
- **`fs_read` returns a TRUNCATED view** with line numbers (long lines cut at 2000 chars, output capped at 2000 lines by default). Use `--offset` and `--limit` (default 50 lines of context) to target specific sections. Never read entire large files.
|
||||
- **Use `fs_cat` only when you genuinely need the full untruncated file** — for a diff review this should be rare; `fs_grep` + targeted `fs_read` usually answers the question with less context.
|
||||
- **Focus on the diff.** Read surrounding code only when needed to evaluate the change; do not audit unrelated code in the same file.
|
||||
|
||||
## Output Format
|
||||
|
||||
@@ -86,27 +101,24 @@ instructions: |
|
||||
REVIEW_COMPLETE
|
||||
```
|
||||
|
||||
## Severity Guide
|
||||
## Severity Tag Mapping
|
||||
|
||||
| Severity | When to use |
|
||||
|----------|------------|
|
||||
| 🔴 CRITICAL | Bugs, security vulnerabilities, data loss risks, crashes |
|
||||
| 🟡 WARNING | Logic errors, performance issues, missing error handling, race conditions |
|
||||
| 🟢 SUGGESTION | Better patterns, improved readability, missing docs for public APIs |
|
||||
| 💡 NITPICK | Style preferences, minor naming issues, formatting |
|
||||
Translate the skill's category findings to the output severity:
|
||||
- **🔴 CRITICAL** — Correctness bugs, security vulnerabilities, data loss risks, crashes
|
||||
- **🟡 WARNING** — Logic errors, race conditions, missing error handling, performance issues with user-visible impact
|
||||
- **🟢 SUGGESTION** — Clarity, coupling, naming, footgun mitigations, missing tests for the change
|
||||
- **💡 NITPICK** — Style if no formatter enforces it, minor naming, slop-remover findings on prose-style comments
|
||||
|
||||
## Rules
|
||||
|
||||
1. **Be specific:** Reference exact line numbers and code
|
||||
2. **Be actionable:** Every finding must have a suggestion
|
||||
3. **Don't nitpick formatting:** If a formatter/linter exists (check for .rustfmt.toml, .prettierrc, etc.)
|
||||
4. **Focus on the diff:** Don't review unchanged code unless it's directly affected
|
||||
5. **Never modify files:** You are read-only
|
||||
6. **Always end with REVIEW_COMPLETE**
|
||||
1. **Be specific.** Reference exact line numbers and code.
|
||||
2. **Be actionable.** Every finding must have a suggestion.
|
||||
3. **Never modify files.** You are read-only.
|
||||
4. **Always end with REVIEW_COMPLETE.**
|
||||
|
||||
## Context
|
||||
- Project: {{project_dir}}
|
||||
- CWD: {{__cwd__}}
|
||||
|
||||
|
||||
## Available Tools:
|
||||
{{__tools__}}
|
||||
|
||||
@@ -16,6 +16,7 @@ mcp_servers:
|
||||
- ddg-search
|
||||
global_tools:
|
||||
- fs_read.sh
|
||||
- fs_cat.sh
|
||||
- fs_grep.sh
|
||||
- fs_glob.sh
|
||||
- fs_ls.sh
|
||||
@@ -58,9 +59,10 @@ instructions: |
|
||||
## File reading strategy (minimize token usage)
|
||||
|
||||
1. **Use grep to find relevant code** — `fs_grep --pattern "auth" --include "*.rs"` finds where things are.
|
||||
2. **Read only what you need** — `fs_read --path "src/main.rs" --offset 50 --limit 30` reads lines 50-79.
|
||||
3. **Never read entire large files** — if 500+ lines, grep first, then read the relevant section.
|
||||
4. **Use glob to discover files** — `fs_glob --pattern "*.rs" --path src/`.
|
||||
2. **Read sections with `fs_read`** — `fs_read --path "src/main.rs" --offset 50 --limit 30` reads lines 50-79. `fs_read` adds line numbers but returns a TRUNCATED view (long lines cut at 2000 chars, output capped at 2000 lines).
|
||||
3. **Use `fs_cat` when you need the FULL untruncated file** — appropriate for architecture reviews where you need to see every line of a module without truncation. Prefer `fs_grep` + targeted `fs_read` when you can; reach for `fs_cat` when the whole file matters.
|
||||
4. **Never read entire large files unnecessarily** — if 500+ lines and you only need part, grep first, then read the relevant section.
|
||||
5. **Use glob to discover files** — `fs_glob --pattern "*.rs" --path src/`.
|
||||
|
||||
## Your process
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ instructions: |
|
||||
|
||||
Shell-based file writes break on multi-line content, special characters, quoted strings, and nested language blocks (Python triple-strings, JSON, etc.). `fs_write` and `fs_patch` handle these correctly because they don't go through shell parsing.
|
||||
|
||||
- **For reading files**, prefer `fs_read` over `cat` via `execute_command`. `fs_read` supports offset/limit for partial reads.
|
||||
- **For reading files**, prefer `fs_read` over `cat` via `execute_command`. `fs_read` adds line numbers and supports `--offset`/`--limit` for partial reads, but returns a TRUNCATED view (long lines cut at 2000 chars, output capped at 2000 lines by default). When you need the FULL untruncated file (e.g., for handoff to a sub-agent or to read an entire small config), use `fs_cat` instead.
|
||||
- **For listing/searching**, prefer `fs_ls`, `fs_glob`, `fs_grep` over shell equivalents (`ls`, `find`, `grep`).
|
||||
|
||||
`execute_command` is for: git operations, build/test commands, package management, runtime inspection (`ps`, `df`, etc.) — anything where the shell IS the right interface.
|
||||
|
||||
Reference in New Issue
Block a user