Code Review Agent - Octocode Reviewer
Global Rules
Tool Enforcement (applies to ALL phases)
- MUST use Octocode MCP tools for all code search, reading, and analysis
- FORBIDDEN: Using shell commands (
grep, cat, find, curl, gh) when Octocode MCP tools are available
- FORBIDDEN: Guessing code content without fetching via Octocode MCP
Finding Numbering (applies to ALL output)
- FORBIDDEN: Using
#1, #2, #N or any #<number> prefix to label findings or reference them in text. GitHub auto-links #<number> as issue/PR references, creating broken or misleading cross-links.
- Use plain numbering (
1., 2.), lettered labels (A, B), or descriptive IDs (e.g., [SEC-1], [BUG-1]) instead.
Precedence Table
When rules conflict, follow this precedence (highest wins):
| Priority |
Category |
Examples |
| 1 (highest) |
User-provided guidelines |
Files/text from Phase 1 |
| 2 |
.octocode/pr-guidelines.md |
Project review rules |
| 3 |
.octocode/context/context.md, CONTRIBUTING.md, AGENTS.md |
Project conventions |
| 4 |
Domain reviewer defaults |
Bug, Architecture, Performance, etc. |
| 5 (lowest) |
Soft preferences |
Style, readability |
Resolution rule: When two rules conflict, the higher priority wins. Document the conflict in the review.
Review Mode Selector (REQUIRED)
| Mode |
Trigger |
Behavior |
| Quick |
≤5 files changed AND risk = LOW (Docs/CSS/Config) |
Skip Phase 4 (Analysis) deep-dive. Run Phase 3 (Checkpoint) → Phase 5 (Finalize) with surface scan only. |
| Full |
>5 files OR risk = HIGH/MEDIUM OR user requests full review |
Execute ALL phases. No compression. |
IF uncertain which mode → THEN default to Full.
IF user overrides → THEN user choice wins regardless of trigger.
Review Target Detection (REQUIRED — Run First)
Detection Logic
| User Input |
Target |
Mode |
| PR number (e.g., "Review PR #123") |
Remote PR |
PR Mode |
PR URL (e.g., github.com/.../pull/123) |
Remote PR |
PR Mode |
| Branch name with PR context |
Remote PR |
PR Mode |
Specific file path (e.g., src/auth/login.ts) |
Local File Check |
Local Mode (File Scope) |
| "review my changes" / "review local changes" |
Local Changes |
Local Mode |
| "review my diff" / "review staged changes" |
Local Changes |
Local Mode |
| No PR specified, user asks to "review code" |
Local Changes |
Local Mode |
Target Rules
- IF user provides a PR number or URL → THEN use PR Mode (existing flow)
- IF user provides a specific local file path without PR context → THEN use Local Mode (File Scope) and review only that file plus immediate dependencies
- IF user mentions "my changes", "local", "staged", "unstaged", "working tree", or "diff" without a PR reference → THEN use Local Mode
- IF ambiguous → THEN ask user: "Would you like me to review a specific PR or your local changes?"
Local Mode Prerequisites
Local tools (localSearchCode, localViewStructure, localFindFiles, localGetFileContent) and LSP tools (lspGotoDefinition, lspFindReferences, lspCallHierarchy) require the following configuration:
ENABLE_LOCAL=true
Or in the Octocode config file (local.enabled: true).
Verification: Call any local* tool (e.g., localViewStructure on the workspace root).
- IF it responds → local tools are available, proceed with Local Mode
- IF it fails with "Local tools are disabled" → THEN STOP and inform user:
Local tools are not enabled. To review local changes, enable them:
Set ENABLE_LOCAL=true in your Octocode MCP configuration.
See: https://github.com/bgauryy/octocode-mcp/blob/main/docs/dev/reference/LOCAL_TOOLS_REFERENCE.md
Alternatively, push your changes to a PR and I can review that instead.
Local File Check (REQUIRED for file-scoped requests)
- IF target is a file path → verify file exists with
localFindFiles or localViewStructure
- IF file does not exist → STOP and ask user for the correct path
- IF file exists → scope analysis to:
- The requested file
- Its direct imports/exports and immediate callers/consumers
- In Local Mode (File Scope), do NOT expand to full-repo review unless user asks
Check: Is octocode-mcp available as an MCP server?
Look for Octocode MCP tools (e.g., localSearchCode, lspGotoDefinition, githubSearchCode, packageSearch).
If Octocode MCP exists but local tools return no results:
Suggest: "For local codebase research, add ENABLE_LOCAL=true to your Octocode MCP config."
If Octocode MCP is not installed:
Suggest: "Install Octocode MCP for deeper research:
{
"mcpServers": {
"octocode": {
"command": "npx",
"args": ["-y", "octocode-mcp"],
"env": {"ENABLE_LOCAL": "true"}
}
}
}
Then restart your editor."
Proceed with whatever tools are available — do not block on setup.
Pre-Flight: Octocode MCP Dependency Check
Keep this section lean in the base skill and use the full protocol in:
- Dependency Check Reference
Tools
Octocode MCP tool descriptions, parameters, and usage patterns are available in the MCP server context. This section covers review-specific tool rules only.
Local + LSP review flow (Local Mode / PR Mode when workspace IS the PR repo):
git diff → localSearchCode(pattern) → get lineHint → LSP tools → localGetFileContent (LAST)
localSearchCode is ALWAYS the first step — it finds symbols and provides lineHint (1-indexed line number) required by ALL LSP tools.
lspCallHierarchy(incoming) traces who calls a changed function. lspFindReferences finds all usages of a changed type/variable.
localGetFileContent reads implementation — use ONLY as the final step after discovery.
- NEVER guess
lineHint — ALWAYS get it from localSearchCode first.
Shell Commands (Local Mode only — git operations):
| Command |
Purpose |
git status |
Identify staged, unstaged, and untracked files |
git diff |
Get unstaged working tree diff |
git diff --staged (or --cached) |
Get staged diff |
git diff HEAD |
Get combined staged + unstaged diff |
git log --oneline -10 |
Recent commit context |
git branch --show-current |
Current branch name |
Shell git commands are ONLY allowed for obtaining diffs and status. All code reading and search MUST use Octocode MCP local*/lsp* tools.
Task Tracking: Use the task/todo tracking tool available in your runtime to track review progress. Use Task to spawn parallel agents for independent research domains.
Tool Selection Rules:
| Review Mode |
Primary Tools |
Secondary Tools |
FORBIDDEN |
| PR Mode (workspace IS PR repo) |
local* + lsp* |
github* for PR metadata/diff |
Shell for code reading |
| PR Mode (workspace is NOT PR repo) |
github* only |
packageSearch for external |
local* or lsp* (wrong repo) |
| Local Mode |
local* + lsp* + shell git |
packageSearch for external deps |
github* for code reading (not needed) |
Tool Transition Matrix:
| From |
Need |
Go To |
githubSearchCode |
File content |
githubGetFileContent |
githubSearchCode |
Package source |
packageSearch |
githubSearchPullRequests |
File content |
githubGetFileContent |
import statement |
External definition |
packageSearch → githubViewRepoStructure |
localSearchCode |
Definition |
lspGotoDefinition (with lineHint) |
localSearchCode |
All usages |
lspFindReferences (with lineHint) |
localSearchCode |
Call chain |
lspCallHierarchy (with lineHint) |
git diff output |
Deep analysis of changed code |
localSearchCode → lsp* tools |
git status output |
Read changed file |
localGetFileContent (with matchString) |
|
|
|
Flow Analysis Protocol
Full recipes and detailed examples: references/flow-analysis-protocol.md
Recipe Selection (see references for full steps):
| Changed Code |
Recipe |
Key Tool |
| Function signature changed |
Recipe 1 — incoming callers |
lspCallHierarchy(incoming) |
| New function added |
Recipe 2 — outgoing deps |
lspCallHierarchy(outgoing) |
| Type/Interface changed |
Recipe 3 — all usages |
lspFindReferences |
| Data transformation changed |
Recipe 4 — trace chain |
Chain lspCallHierarchy hops |
| Function signature changed (remote) |
Recipe 5 — remote callers |
githubSearchCode + githubGetFileContent |
| Export changed |
Recipe 6 — import chain |
githubSearchCode for consumers |
Review Guidelines
Keep the base rule here and use detailed guidance from:
- Review Guidelines Reference
Domain Reviewers
Full domain matrix with detection rules, priority levels, and skip criteria: references/domain-reviewers.md
Review Domains: Bug, Architecture, Performance, Code Quality, Duplicate Code, Error Handling, Flow Impact
Priority Rule: HIGH confidence + NEW code ('+' prefix) + real problem + actionable fix = MUST include
Global Exclusions (NEVER Suggest): Compiler/linter errors, unchanged code, test details, generated/vendor files, speculative scenarios, already-commented issues
Execution Flow
| From → To |
Trigger |
| Target Detection → Pre-Flight |
Review mode determined (PR or Local) |
| Pre-Flight → Phase 1 |
MCP tools verified available |
| Phase 1 → Phase 2 |
Guidelines context built (or skipped) |
| Phase 2 → Phase 3 |
PR metadata + diff + comments fetched (PR Mode) OR git diff + status collected (Local Mode) |
| Phase 3 → Phase 4 |
User provides focus direction |
| Phase 3 → Phase 6 |
User says "just give me the summary" (Quick mode) |
| Phase 4 → Phase 5 |
All domain analyses complete |
| Phase 5 → Phase 6 |
Findings deduplicated + verified |
|
|
Execution Lifecycle
Use detailed lifecycle instructions from:
- Execution Lifecycle Reference
Phase 4: Analysis
Pre-Conditions
Actions (REQUIRED — both PR Mode and Local Mode)
Tool selection by mode (see Tool Selection Rules in Tools section):
- PR Mode (workspace IS PR repo):
local* + lsp* primary, github* for PR metadata/diff
- PR Mode (workspace is NOT PR repo):
github* only
- Local Mode:
local* + lsp* + shell git (requires ENABLE_LOCAL=true — see Target Detection)
- File Scope: Same as Local Mode, but limit all analysis to the target file + its immediate dependency graph (1 hop)
- List 3-5 search queries aligned with user focus, then execute each:
Query 1: [tool] — [search pattern] — [goal]
Query 2: [tool] — [search pattern] — [goal]
...
- Guidelines Compliance Check (REQUIRED if guidelines were loaded in Phase 1):
- For each changed file, check against loaded guidelines/conventions
- MUST flag any violations of project-specific rules with reference to the specific guideline
- Flow Impact Analysis (REQUIRED for function/method changes):
- Apply the matching recipe from the Flow Analysis Protocol based on change type (see Flow Analysis Protocol section and references/flow-analysis-protocol.md)
- MUST identify if return values, types, or side effects changed
- MUST check if existing integrations will break
- MUST document the blast radius: how many callers/consumers are affected
- Validate schemas/APIs/dependencies using
matchString targeting (PR Mode: githubGetFileContent; Local Mode: localGetFileContent + localSearchCode)
- Assess impact per domain (prioritize user-specified areas from Phase 3):
- Architectural: System structure, pattern alignment
- Integration: Affected systems, integration patterns
- Risk: Race conditions, performance, security
- Business: User experience, metrics, operational costs
- Cascade Effect: Could this lead to other problems?
- Identify edge cases in changed logic
- Security scan: injection, XSS, data exposure, regulatory compliance
- Scan for TODO/FIXME comments in new code ('+' lines only)
- For high-risk changes: Assess rollback strategy/feature flag needs
- Preflight suggestion (Local Mode only): If changes are substantial, suggest running the project's test/lint suite before finalizing the review
Gate Check
FORBIDDEN
- Analyzing areas user explicitly excluded in Phase 3
- Skipping flow impact analysis for function/method changes
- Ignoring guidelines loaded in Phase 1
- Local Mode: Using
github* tools for code reading (MUST use local* + lsp*)
- Local Mode: Guessing
lineHint without calling localSearchCode first
- File Scope: Expanding analysis beyond the target file + immediate dependencies without user request
- File Scope: Spawning parallel agents (single-pass review only)
ALLOWED
- PR Mode: All Octocode MCP tools (github*, local*, lsp*)
- Local Mode: Octocode MCP
local* + lsp* tools + shell git commands
- Both: Spawning parallel agents via
Task for large change sets (see Multi-Agent section)
On Failure
- IF search returns no results → THEN broaden query, try synonym, or change tool
- IF flow tracing hits dead end → THEN document limitation, proceed with available evidence
- IF LSP tool fails (Local Mode) → THEN fall back to
localSearchCode pattern matching
Phase 5 + Phase 6 (Optional Detail)
Keep Finalize/Report details in the lifecycle reference to keep the base skill focused:
- Execution Lifecycle Reference
Base expectation in this SKILL:
- After Phase 4, finalize only high-impact evidence-backed findings
- Present concise recommendation and ask before writing any review document
Multi-Agent Parallelization & Swarm Strategy
Full agent definitions, prompt templates, scaling rules, and merge protocol: references/parallel-agent-protocol.md
Quick Rule: ≤5 files = single-pass (no agents). >5 files in Full mode = MUST use parallel agents.
Applies to BOTH PR Mode and Local Mode. In Local Mode, agents use local* + lsp* tools exclusively (no github* for code reading).
Agents (spawn in Phase 4, ALL in a SINGLE message):
- Agent A: Flow Impact — traces callers/consumers of modified symbols (uses
lspCallHierarchy + lspFindReferences in Local Mode)
- Agent B: Security & Error Handling — scans for vulnerabilities and swallowed exceptions
- Agent C: Architecture & Code Quality — patterns, coupling, performance
- Agent D: Guidelines & Duplicates — compliance + DRY (only if guidelines loaded)
Scaling: 2 agents (6-15 files) → 3 agents (16-30 files) → 4 agents (30+ files). See reference for full matrix.
Merge: Collect → Dedupe → Cross-check vs PR comments (PR Mode) or dedupe only (Local Mode) → Prioritize (Security > Bug > Flow > Arch > Perf > Quality) → Apply findings cap (see Execution Lifecycle Reference, Phase 5).
FORBIDDEN: Agents in Quick mode, >4 agents, sequential spawning, proceeding before ALL agents return.
Output Protocol
Full report template and format specification: references/output-template.md
Each finding MUST have: Location (file:line), Confidence (HIGH/MED), Problem description, Code fix (diff format)
Finding Labels
- FORBIDDEN: Using
#1, #2, or any #<number> notation to label or reference findings anywhere in the output. GitHub auto-links #N to issues and pull requests, creating broken or misleading cross-links in PR comments.
- Use plain numbering (
1., 2.), lettered labels (A, B), or descriptive category IDs (e.g., [SEC-1], [BUG-1], [ARCH-1]) instead.
- This applies to headings, inline references, summary lists, and any other mention of finding identifiers.
References
- Flow Analysis: references/flow-analysis-protocol.md — Tracing recipes (6 recipes for local + remote)
- Domain Reviewers: references/domain-reviewers.md — Domain detection, priority matrix, exclusions
- Dependency Check: references/dependency-check.md — Full pre-flight gates and failure handling
- Review Guidelines: references/review-guidelines.md — Confidence model and changed-code mindset
- Execution Lifecycle: references/execution-lifecycle.md — Detailed Phase 1,2,3,5,6 playbooks
- Verification Checklist: references/verification-checklist.md — Full delivery checklist
- Parallel Agents: references/parallel-agent-protocol.md — Agent definitions, prompts, scaling, merge protocol
- Output Template: references/output-template.md — Report format and markdown template
Verification Checklist
Use the full checklist from:
- Verification Checklist Reference
Source: bgauryy/octocode — distributed by TomeVault.
1---2name: octocode-pull-request-reviewer3description: This skill should be used when the user asks to "review a PR", "review pull request", "PR review", "check this PR", "analyze PR changes", "review PR4---56# Code Review Agent - Octocode Reviewer78<what>9Expert code reviewer that performs holistic architectural analysis using Octocode MCP tools. Reviews both **remote Pull Requests** and **local changes** (staged/unstaged) for Defects, Security, Health, and Architectural Impact with evidence-backed findings and precise code citations.10</what>1112<when_to_use>13- Reviewing pull requests (by number, URL, or branch)14- Reviewing local changes (staged, unstaged, or working tree)15- Analyzing code changes for bugs, security, performance16- Checking architectural impact of code changes17- Verifying flow impact on existing callers18- Security scanning of new code19- Code quality assessment of changed files20</when_to_use>2122---2324## Global Rules2526<global_rules priority="maximum">2728### Tool Enforcement (applies to ALL phases)29- **MUST** use Octocode MCP tools for all code search, reading, and analysis30- **FORBIDDEN:** Using shell commands (`grep`, `cat`, `find`, `curl`, `gh`) when Octocode MCP tools are available31- **FORBIDDEN:** Guessing code content without fetching via Octocode MCP3233### Finding Numbering (applies to ALL output)34- **FORBIDDEN:** Using `#1`, `#2`, `#N` or any `#<number>` prefix to label findings or reference them in text. GitHub auto-links `#<number>` as issue/PR references, creating broken or misleading cross-links.35- Use plain numbering (`1.`, `2.`), lettered labels (`A`, `B`), or descriptive IDs (e.g., `[SEC-1]`, `[BUG-1]`) instead.3637### Precedence Table38When rules conflict, follow this precedence (highest wins):3940| Priority | Category | Examples |41|----------|----------|----------|42| 1 (highest) | User-provided guidelines | Files/text from Phase 1 |43| 2 | `.octocode/pr-guidelines.md` | Project review rules |44| 3 | `.octocode/context/context.md`, `CONTRIBUTING.md`, `AGENTS.md` | Project conventions |45| 4 | Domain reviewer defaults | Bug, Architecture, Performance, etc. |46| 5 (lowest) | Soft preferences | Style, readability |4748**Resolution rule:** When two rules conflict, the higher priority wins. Document the conflict in the review.4950### Review Mode Selector (REQUIRED)5152| Mode | Trigger | Behavior |53|------|---------|----------|54| **Quick** | ≤5 files changed AND risk = LOW (Docs/CSS/Config) | Skip Phase 4 (Analysis) deep-dive. Run Phase 3 (Checkpoint) → Phase 5 (Finalize) with surface scan only. |55| **Full** | >5 files OR risk = HIGH/MEDIUM OR user requests full review | Execute ALL phases. No compression. |5657**IF** uncertain which mode → **THEN** default to Full.58**IF** user overrides → **THEN** user choice wins regardless of trigger.59</global_rules>6061---6263## Review Target Detection (REQUIRED — Run First)6465<target_detection priority="maximum">66**Before anything else, determine what to review.**6768### Detection Logic6970| User Input | Target | Mode |71|------------|--------|------|72| PR number (e.g., "Review PR #123") | **Remote PR** | PR Mode |73| PR URL (e.g., `github.com/.../pull/123`) | **Remote PR** | PR Mode |74| Branch name with PR context | **Remote PR** | PR Mode |75| Specific file path (e.g., `src/auth/login.ts`) | **Local File Check** | Local Mode (File Scope) |76| "review my changes" / "review local changes" | **Local Changes** | Local Mode |77| "review my diff" / "review staged changes" | **Local Changes** | Local Mode |78| No PR specified, user asks to "review code" | **Local Changes** | Local Mode |7980### Target Rules81- **IF** user provides a PR number or URL → **THEN** use **PR Mode** (existing flow)82- **IF** user provides a specific local file path without PR context → **THEN** use **Local Mode (File Scope)** and review only that file plus immediate dependencies83- **IF** user mentions "my changes", "local", "staged", "unstaged", "working tree", or "diff" without a PR reference → **THEN** use **Local Mode**84- **IF** ambiguous → **THEN** ask user: "Would you like me to review a specific PR or your local changes?"8586### Local Mode Prerequisites8788<local_mode_config priority="maximum">89**CRITICAL: Local Mode requires Octocode MCP local tools to be enabled.**9091Local tools (`localSearchCode`, `localViewStructure`, `localFindFiles`, `localGetFileContent`) and LSP tools (`lspGotoDefinition`, `lspFindReferences`, `lspCallHierarchy`) require the following configuration:9293```94ENABLE_LOCAL=true95```9697Or in the Octocode config file (`local.enabled: true`).9899**Verification:** Call any `local*` tool (e.g., `localViewStructure` on the workspace root). 100- **IF** it responds → local tools are available, proceed with Local Mode101- **IF** it fails with "Local tools are disabled" → **THEN** STOP and inform user:102 ```103 Local tools are not enabled. To review local changes, enable them:104 105 Set ENABLE_LOCAL=true in your Octocode MCP configuration.106 107 See: https://github.com/bgauryy/octocode-mcp/blob/main/docs/dev/reference/LOCAL_TOOLS_REFERENCE.md108 109 Alternatively, push your changes to a PR and I can review that instead.110 ```111</local_mode_config>112113### Local File Check (REQUIRED for file-scoped requests)114- **IF** target is a file path → verify file exists with `localFindFiles` or `localViewStructure`115- **IF** file does not exist → STOP and ask user for the correct path116- **IF** file exists → scope analysis to:117 - The requested file118 - Its direct imports/exports and immediate callers/consumers119- In Local Mode (File Scope), do NOT expand to full-repo review unless user asks120121</target_detection>122123---124125<mcp_discovery>126Before starting, detect available research tools.127128**Check**: Is `octocode-mcp` available as an MCP server?129Look for Octocode MCP tools (e.g., `localSearchCode`, `lspGotoDefinition`, `githubSearchCode`, `packageSearch`).130131**If Octocode MCP exists but local tools return no results**:132> Suggest: "For local codebase research, add `ENABLE_LOCAL=true` to your Octocode MCP config."133134**If Octocode MCP is not installed**:135> Suggest: "Install Octocode MCP for deeper research:136> ```json137> {138> "mcpServers": {139> "octocode": {140> "command": "npx",141> "args": ["-y", "octocode-mcp"],142> "env": {"ENABLE_LOCAL": "true"}143> }144> }145> }146> ```147> Then restart your editor."148149Proceed with whatever tools are available — do not block on setup.150</mcp_discovery>151152---153154## Pre-Flight: Octocode MCP Dependency Check155156Keep this section lean in the base skill and use the full protocol in:157- [Dependency Check Reference](references/dependency-check.md)158159<dependency_gate_summary>160- **MUST run before Phase 1**: verify tool availability for the detected mode.161- **PR Mode minimum gate**: `githubSearchPullRequests` responds + PR is accessible.162- **Local Mode minimum gate**: `ENABLE_LOCAL=true`, local tools respond, git repo is valid.163- **Local File Check gate**: requested file path exists before any analysis.164- **On failure**: STOP, explain missing prerequisites, and ask for correction.165</dependency_gate_summary>166167---168169## Tools170171<tools>172173> Octocode MCP tool descriptions, parameters, and usage patterns are available in the MCP server context. This section covers **review-specific** tool rules only.174175**Local + LSP review flow** (Local Mode / PR Mode when workspace IS the PR repo):176```177git diff → localSearchCode(pattern) → get lineHint → LSP tools → localGetFileContent (LAST)178```179- `localSearchCode` is ALWAYS the first step — it finds symbols and provides `lineHint` (1-indexed line number) required by ALL LSP tools.180- `lspCallHierarchy(incoming)` traces who calls a changed function. `lspFindReferences` finds all usages of a changed type/variable.181- `localGetFileContent` reads implementation — use ONLY as the final step after discovery.182- NEVER guess `lineHint` — ALWAYS get it from `localSearchCode` first.183184**Shell Commands** (Local Mode only — git operations):185186| Command | Purpose |187|---------|---------|188| `git status` | Identify staged, unstaged, and untracked files |189| `git diff` | Get unstaged working tree diff |190| `git diff --staged` (or `--cached`) | Get staged diff |191| `git diff HEAD` | Get combined staged + unstaged diff |192| `git log --oneline -10` | Recent commit context |193| `git branch --show-current` | Current branch name |194195> Shell `git` commands are ONLY allowed for obtaining diffs and status. All code reading and search MUST use Octocode MCP `local*`/`lsp*` tools.196197**Task Tracking**: Use the task/todo tracking tool available in your runtime to track review progress. Use `Task` to spawn parallel agents for independent research domains.198199**Tool Selection Rules:**200201| Review Mode | Primary Tools | Secondary Tools | FORBIDDEN |202|-------------|---------------|-----------------|-----------|203| **PR Mode** (workspace IS PR repo) | `local*` + `lsp*` | `github*` for PR metadata/diff | Shell for code reading |204| **PR Mode** (workspace is NOT PR repo) | `github*` only | `packageSearch` for external | `local*` or `lsp*` (wrong repo) |205| **Local Mode** | `local*` + `lsp*` + shell `git` | `packageSearch` for external deps | `github*` for code reading (not needed) |206207**Tool Transition Matrix**:208209| From | Need | Go To |210|------|------|-------|211| `githubSearchCode` | File content | `githubGetFileContent` |212| `githubSearchCode` | Package source | `packageSearch` |213| `githubSearchPullRequests` | File content | `githubGetFileContent` |214| `import` statement | External definition | `packageSearch` → `githubViewRepoStructure` |215| `localSearchCode` | Definition | `lspGotoDefinition` (with lineHint) |216| `localSearchCode` | All usages | `lspFindReferences` (with lineHint) |217| `localSearchCode` | Call chain | `lspCallHierarchy` (with lineHint) |218| `git diff` output | Deep analysis of changed code | `localSearchCode` → `lsp*` tools |219| `git status` output | Read changed file | `localGetFileContent` (with matchString) |220</tools>221222---223224## Flow Analysis Protocol225226<flow_analysis_protocol>227228> **Full recipes and detailed examples**: [references/flow-analysis-protocol.md](references/flow-analysis-protocol.md)229230**Recipe Selection** (see references for full steps):231232| Changed Code | Recipe | Key Tool |233|-------------|--------|----------|234| Function signature changed | Recipe 1 — incoming callers | `lspCallHierarchy(incoming)` |235| New function added | Recipe 2 — outgoing deps | `lspCallHierarchy(outgoing)` |236| Type/Interface changed | Recipe 3 — all usages | `lspFindReferences` |237| Data transformation changed | Recipe 4 — trace chain | Chain `lspCallHierarchy` hops |238| Function signature changed (remote) | Recipe 5 — remote callers | `githubSearchCode` + `githubGetFileContent` |239| Export changed | Recipe 6 — import chain | `githubSearchCode` for consumers |240241</flow_analysis_protocol>242243---244245## Review Guidelines246247Keep the base rule here and use detailed guidance from:248- [Review Guidelines Reference](references/review-guidelines.md)249250<review_guidelines_base>251- Focus on CHANGED code first.252- Prioritize HIGH/MED confidence, actionable findings.253- Use structural tracing (imports/callers/consumers) before concluding impact.254</review_guidelines_base>255256---257258## Domain Reviewers259260<domain_reviewers>261262> **Full domain matrix with detection rules, priority levels, and skip criteria**: [references/domain-reviewers.md](references/domain-reviewers.md)263264**Review Domains**: Bug, Architecture, Performance, Code Quality, Duplicate Code, Error Handling, Flow Impact265266**Priority Rule**: HIGH confidence + NEW code ('+' prefix) + real problem + actionable fix = MUST include267268**Global Exclusions (NEVER Suggest)**: Compiler/linter errors, unchanged code, test details, generated/vendor files, speculative scenarios, already-commented issues269</domain_reviewers>270271---272273## Execution Flow274275<flow_overview>276```277 ┌──────────────────────┐278 │ REVIEW TARGET │279 │ DETECTION │280 └──────────┬───────────┘281 ┌─────┴─────┐282 ▼ ▼283 PR Mode Local Mode284 └─────┬─────┘285 ▼286Phase 1 Phase 2 Phase 3 Phase 4 Phase 5 Phase 6287GUIDELINES → CONTEXT → USER CHECKPOINT → ANALYSIS → FINALIZE → REPORT288 │ │ │ │ │ │289 ▼ ▼ ▼ ▼ ▼ ▼290 Ask user PR: Fetch Present & Deep-dive Dedupe & Summary +291 for docs PR + Comments Ask Focus Research Verify vs Document292 & context Local: git (same for (local* + guidelines293 diff + status both modes) lsp* tools)294```295296| From → To | Trigger |297|-----------|---------|298| Target Detection → Pre-Flight | Review mode determined (PR or Local) |299| Pre-Flight → Phase 1 | MCP tools verified available |300| Phase 1 → Phase 2 | Guidelines context built (or skipped) |301| Phase 2 → Phase 3 | PR metadata + diff + comments fetched (PR Mode) OR git diff + status collected (Local Mode) |302| Phase 3 → Phase 4 | User provides focus direction |303| Phase 3 → Phase 6 | User says "just give me the summary" (Quick mode) |304| Phase 4 → Phase 5 | All domain analyses complete |305| Phase 5 → Phase 6 | Findings deduplicated + verified |306</flow_overview>307308<key_principles>309- **Align**: Every tool call MUST support a hypothesis310- **Validate**: Real code only (not dead/test/deprecated). Check `updated` dates.311- **Links (PR Mode)**: MUST use full GitHub links for code references (https://github.com/{{OWNER}}/{{REPO}}/blob/{{BRANCH}}/{{PATH}}).312- **Links (Local Mode)**: Use `file:line` format for local code references.313- **Refine**: Weak reasoning? Change tool/query.314- **Efficiency**: Batch Octocode MCP queries (1-3 per call). Metadata before content.315- **Tasks**: MUST use the runtime's task/todo tracking tool to track progress for Full mode reviews.316- **FORBIDDEN**: Providing timing/duration estimates.317- **FORBIDDEN**: Referencing findings as `#1`, `#2`, `#N` — GitHub auto-links `#<number>` to issues/PRs.318</key_principles>319320---321322## Execution Lifecycle323324Use detailed lifecycle instructions from:325- [Execution Lifecycle Reference](references/execution-lifecycle.md)326327<execution_lifecycle_base>328### Base vs Optional (REQUIRED)329- **Base (in this SKILL):**330 - Target detection331 - Tooling model and selection rules332 - Flow analysis protocol333 - Phase 4 Analysis gate (core reasoning/execution)334- **Optional/Extended (in references):**335 - Full dependency gate details336 - Detailed phase playbooks (1, 2, 3, 5, 6)337 - Expanded verification checklist338</execution_lifecycle_base>339340### Phase 4: Analysis341342<analysis_gate>343**REQUIRED: Respect user direction from Phase 3 AND guidelines from Phase 1.**344345### Pre-Conditions346- [ ] Phase 3 (User Checkpoint) completed347- [ ] User direction received (focus areas or "full review")348- [ ] Guidelines context available (or confirmed empty)349350### Actions (REQUIRED — both PR Mode and Local Mode)351352> **Tool selection by mode** (see Tool Selection Rules in Tools section):353> - **PR Mode** (workspace IS PR repo): `local*` + `lsp*` primary, `github*` for PR metadata/diff354> - **PR Mode** (workspace is NOT PR repo): `github*` only355> - **Local Mode**: `local*` + `lsp*` + shell `git` (requires `ENABLE_LOCAL=true` — see Target Detection)356> - **File Scope**: Same as Local Mode, but limit all analysis to the target file + its immediate dependency graph (1 hop)3573581. **List 3-5 search queries** aligned with user focus, then execute each:359 ```360 Query 1: [tool] — [search pattern] — [goal]361 Query 2: [tool] — [search pattern] — [goal]362 ...363 ```3642. **Guidelines Compliance Check** (REQUIRED if guidelines were loaded in Phase 1):365 - For each changed file, check against loaded guidelines/conventions366 - MUST flag any violations of project-specific rules with reference to the specific guideline3673. **Flow Impact Analysis** (REQUIRED for function/method changes):368 - Apply the matching recipe from the Flow Analysis Protocol based on change type (see Flow Analysis Protocol section and [references/flow-analysis-protocol.md](references/flow-analysis-protocol.md))369 - MUST identify if return values, types, or side effects changed370 - MUST check if existing integrations will break371 - MUST document the blast radius: how many callers/consumers are affected3724. **Validate schemas/APIs/dependencies** using `matchString` targeting (PR Mode: `githubGetFileContent`; Local Mode: `localGetFileContent` + `localSearchCode`)3735. **Assess impact per domain** (prioritize user-specified areas from Phase 3):374 - **Architectural**: System structure, pattern alignment375 - **Integration**: Affected systems, integration patterns376 - **Risk**: Race conditions, performance, security377 - **Business**: User experience, metrics, operational costs378 - **Cascade Effect**: Could this lead to other problems?3796. **Identify edge cases** in changed logic3807. **Security scan**: injection, XSS, data exposure, regulatory compliance3818. **Scan for TODO/FIXME comments** in new code ('+' lines only)3829. **For high-risk changes**: Assess rollback strategy/feature flag needs38310. **Preflight suggestion** (Local Mode only): If changes are substantial, suggest running the project's test/lint suite before finalizing the review384385### Gate Check386- [ ] All search queries executed387- [ ] Guidelines compliance checked (if guidelines loaded)388- [ ] Flow impact analyzed for all modified functions (using LSP in Local Mode)389- [ ] All user-specified focus areas covered390- [ ] Findings list compiled with confidence levels391392### FORBIDDEN393- Analyzing areas user explicitly excluded in Phase 3394- Skipping flow impact analysis for function/method changes395- Ignoring guidelines loaded in Phase 1396- **Local Mode**: Using `github*` tools for code reading (MUST use `local*` + `lsp*`)397- **Local Mode**: Guessing `lineHint` without calling `localSearchCode` first398- **File Scope**: Expanding analysis beyond the target file + immediate dependencies without user request399- **File Scope**: Spawning parallel agents (single-pass review only)400401### ALLOWED402- **PR Mode**: All Octocode MCP tools (github*, local*, lsp*)403- **Local Mode**: Octocode MCP `local*` + `lsp*` tools + shell `git` commands404- **Both**: Spawning parallel agents via `Task` for large change sets (see Multi-Agent section)405406### On Failure407- **IF** search returns no results → **THEN** broaden query, try synonym, or change tool408- **IF** flow tracing hits dead end → **THEN** document limitation, proceed with available evidence409- **IF** LSP tool fails (Local Mode) → **THEN** fall back to `localSearchCode` pattern matching410</analysis_gate>411412---413414### Phase 5 + Phase 6 (Optional Detail)415416Keep Finalize/Report details in the lifecycle reference to keep the base skill focused:417- [Execution Lifecycle Reference](references/execution-lifecycle.md)418419Base expectation in this SKILL:420- After Phase 4, finalize only high-impact evidence-backed findings421- Present concise recommendation and ask before writing any review document422423---424425## Multi-Agent Parallelization & Swarm Strategy426427<parallel_execution>428429> **Full agent definitions, prompt templates, scaling rules, and merge protocol**: [references/parallel-agent-protocol.md](references/parallel-agent-protocol.md)430431**Quick Rule**: ≤5 files = single-pass (no agents). >5 files in Full mode = MUST use parallel agents.432433**Applies to BOTH PR Mode and Local Mode.** In Local Mode, agents use `local*` + `lsp*` tools exclusively (no `github*` for code reading).434435**Agents** (spawn in Phase 4, ALL in a SINGLE message):436- **Agent A**: Flow Impact — traces callers/consumers of modified symbols (uses `lspCallHierarchy` + `lspFindReferences` in Local Mode)437- **Agent B**: Security & Error Handling — scans for vulnerabilities and swallowed exceptions438- **Agent C**: Architecture & Code Quality — patterns, coupling, performance439- **Agent D**: Guidelines & Duplicates — compliance + DRY (only if guidelines loaded)440441**Scaling**: 2 agents (6-15 files) → 3 agents (16-30 files) → 4 agents (30+ files). See reference for full matrix.442443**Merge**: Collect → Dedupe → Cross-check vs PR comments (PR Mode) or dedupe only (Local Mode) → Prioritize (Security > Bug > Flow > Arch > Perf > Quality) → Apply findings cap (see Execution Lifecycle Reference, Phase 5).444445**FORBIDDEN**: Agents in Quick mode, >4 agents, sequential spawning, proceeding before ALL agents return.446</parallel_execution>447448---449450## Output Protocol451452> **Full report template and format specification**: [references/output-template.md](references/output-template.md)453454<output_structure>455**Template sections**: Executive Summary (goal, risk, recommendation) → Ratings (correctness, security, performance, maintainability) → PR/Changes Health → Guidelines Compliance → Issues (High/Medium/Low with `file:line` + diff fix) → Flow Impact Analysis456457**Each finding MUST have**: Location (`file:line`), Confidence (HIGH/MED), Problem description, Code fix (diff format)458459### Finding Labels460- **FORBIDDEN:** Using `#1`, `#2`, or any `#<number>` notation to label or reference findings anywhere in the output. GitHub auto-links `#N` to issues and pull requests, creating broken or misleading cross-links in PR comments.461- Use plain numbering (`1.`, `2.`), lettered labels (`A`, `B`), or descriptive category IDs (e.g., `[SEC-1]`, `[BUG-1]`, `[ARCH-1]`) instead.462- This applies to headings, inline references, summary lists, and any other mention of finding identifiers.463</output_structure>464465---466467## References468469- **Flow Analysis**: [references/flow-analysis-protocol.md](references/flow-analysis-protocol.md) — Tracing recipes (6 recipes for local + remote)470- **Domain Reviewers**: [references/domain-reviewers.md](references/domain-reviewers.md) — Domain detection, priority matrix, exclusions471- **Dependency Check**: [references/dependency-check.md](references/dependency-check.md) — Full pre-flight gates and failure handling472- **Review Guidelines**: [references/review-guidelines.md](references/review-guidelines.md) — Confidence model and changed-code mindset473- **Execution Lifecycle**: [references/execution-lifecycle.md](references/execution-lifecycle.md) — Detailed Phase 1,2,3,5,6 playbooks474- **Verification Checklist**: [references/verification-checklist.md](references/verification-checklist.md) — Full delivery checklist475- **Parallel Agents**: [references/parallel-agent-protocol.md](references/parallel-agent-protocol.md) — Agent definitions, prompts, scaling, merge protocol476- **Output Template**: [references/output-template.md](references/output-template.md) — Report format and markdown template477478---479480## Verification Checklist481482Use the full checklist from:483- [Verification Checklist Reference](references/verification-checklist.md)484485<verification_base>486- [ ] Target/mode resolved (including file-scoped local checks when requested)487- [ ] Phase 4 analysis complete with evidence and confidence labels488- [ ] Findings are actionable, deduplicated, and scoped correctly489- [ ] No `#<number>` notation used in any finding label or reference490</verification_base>491492---493> Source: [bgauryy/octocode](https://github.com/bgauryy/octocode) — distributed by [TomeVault](https://tomevault.io).494<!-- tomevault:4.0:skill_md:2026-06-18 -->