octocode-cli
Octocode CLI — Agent Playbook
Six subcommands, one tool each. Pick by task shape. Always add --json and pipe to jq.
Task → Command
| What you need | Command | Key flags |
|---|---|---|
| Find where a symbol is defined or used | search-code |
--query 'symbol' --owner X --repo Y |
| Read a specific file (whole or a window) | get-file |
--match-string 'anchor' or --start-line N --end-line M or --full-content |
| Map a repo's layout | view-structure |
--depth 2 |
| Find repos by topic/popularity | search-repos |
--topics a,b --stars '>=100' |
| PR history on a repo | search-prs |
--owner X --repo Y --merged |
| Resolve a package to a repo + read metadata | package-search |
--name pkg --ecosystem npm |
Core discipline
These three rules decide whether the CLI is fast or slow:
- Parallelize independent calls. Need files A, B, C from one repo? Issue all three
get-filecalls in one message so the shell runs them concurrently. Sequential loops waste wall-clock. - One wide query beats five narrow ones. First
search-codeshould be the broadest that plausibly returns <20 hits. If you got reasonable results, read them — don't re-query to "narrow down". Iteratingsearch-codeis the #1 reason the CLI ever feels slow. - Bulk via stdin when the same command runs >2 times. One process start beats N.
printf '{"queries":[
{"keywordsToSearch":["useState"],"owner":"facebook","repo":"react"},
{"keywordsToSearch":["useEffect"],"owner":"facebook","repo":"react"}
]}' | octocode-cli search-code --json | jq
Recipes by task shape
Symbol lookup (find definition + a few callers)
# One search returns the defining file and call sites together
octocode-cli search-code --query 'runCLI' --owner bgauryy --repo octocode-mcp --limit 10 --json | jq
# Read the hit that looks like the definition
octocode-cli get-file --owner bgauryy --repo octocode-mcp \
--path packages/octocode-cli/src/cli/index.ts \
--match-string 'export function runCLI' --json | jq
Workspace mapping (list packages + read each package.json)
# Structure first — one call, entire tree
octocode-cli view-structure --owner bgauryy --repo octocode-mcp --depth 2 --json | jq
Then fetch every package.json in a single message by issuing parallel get-file calls (your agent's parallel tool-use, not a sequential loop). A 5-package mapping is 1 structure call + 5 parallel fetches = 2 round-trips, not 6.
Cross-repo symbol search
# ONE search with a distinctive keyword. The top hit's path is the answer.
octocode-cli search-code --query 'discriminatedUnion' --owner colinhacks --repo zod --limit 5 --json | jq
Don't re-query to "confirm". Once you have a path that plausibly defines the symbol, answer from it.
Call-chain trace
# Seed with the entry function
octocode-cli search-code --query 'runCLI' --owner bgauryy --repo octocode-mcp --json | jq
For each callee name you find, search it to locate the next hop. 3–4 search-code calls reach a handler; 10+ means you're lost — back out and try a broader seed query.
Flags at a glance
- Lists are comma-separated:
--query 'a,b,c'→['a','b','c']. - Kebab → camel:
--match-string→matchString,--full-content→fullContent. - Boolean flags take no value:
--merged,--draft,--full-content,--with-comments,--with-commits,--npm-fetch-metadata,--python-fetch-metadata. - Numeric flags:
--limit,--depth,--start-line,--end-line. Non-numeric exits1. id,mainResearchGoal,researchGoal,reasoningare auto-filled — don't pass them.--jsonprints compactstructuredContentonly (no text preamble, no envelope). Byte-equivalent to MCP payload. Pipe intojq.- Exit
0on success,1on missing flag / bad stdin / validation / tool error.
Auth
Uses Octocode-stored creds or gh CLI token, in that order.
octocode-cli login # or: gh auth login
More from bgauryy/octocode-mcp
octocode-research
Use when the user asks to "research code", "how does X work", "where is Y defined", "who calls Z", "trace code flow", "find usages", "explore this library", "understand the codebase", or needs deep code exploration with HTTP-based tool orchestration. For direct MCP tool research without the HTTP server, use octocode-researcher instead.
192octocode-prompt-optimizer
This skill should be used when the user asks to "optimize this prompt", "improve this SKILL.md", "make this prompt more reliable", "fix my agent instructions", "review this AGENTS.md", "strengthen this prompt", "my agent keeps skipping steps", "add enforcement to instructions", or needs to transform weak prompts into reliable, enforceable agent protocols. Uses a 6-step gated flow (with Fast/Full modes), command strengthening, gate injection, and failure mode analysis.
54octocode-documentation-writer
This skill should be used when the user asks to "generate documentation", "document this project", "create docs", "write documentation", "update documentation", "document all APIs", "generate onboarding docs", "create developer docs", or needs comprehensive codebase documentation. Orchestrates parallel AI agents to analyze code and produce documentation files.
53octocode-pull-request-reviewer
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 PR #123", "what''s wrong with this PR", "is this PR safe to merge", "review my changes", "review local changes", "review my code", "review staged changes", "review my diff", or needs expert code review with architectural analysis, defect detection, and security scanning. Supports both remote PRs and local changes (staged/unstaged). Uses Octocode MCP tools for deep code forensics and holistic evaluation.
52octocode-plan
Use when the user asks to "plan & implement", "plan this work", "research & build", "plan auth/API/work", or needs a multi-step pipeline from understanding through implementation. Flow is Understand → Research → Plan → Implement → Verify. For design documents or technical proposals without implementation, use octocode-rfc-generator instead.
39octocode-researcher
Primary research skill — use when the user asks to research, search, explore, find, trace, investigate, or understand code. Triggers include "find X", "where is Y defined?", "explore this dir", "trace definitions", "find usages", "how does X work?", "who calls Z?", "search for X", "research this library", "find PRs", "what package does X?", "understand this flow", "investigate this bug", "what changed?", or any code exploration/discovery need — local or external. Uses Octocode MCP tools directly (preferred). Falls back to gh CLI or Linux tools when MCP is unavailable.
9