repo-explorer

$npx mdskill add CodeAlive-AI/ai-driven-development/repo-explorer

Launch a CLI process to explore and answer questions about a repository

  • Determine the source (local path, remote URL, or shorthand) of the repository.
  • Identify the user's question about the repository structure, API, architecture, or implementation details.
  • Use Claude Code CLI in non-interactive mode with read-only access to explore and analyze the repository.
  • Deliver results back to the user via the agent, such as JSON responses or markdown summaries.

SKILL.md

.github/skills/repo-explorerView on GitHub ↗
---
name: repo-explorer
description: >
  Explore and analyze any repository (local path or remote GitHub/GitLab URL) by
  delegating to Claude Code CLI (`claude -p`) in non-interactive mode with read-only
  access. Use when the user asks to explore, analyze, investigate, or research a
  repository or codebase. Triggers on "explore repo", "analyze repo", "investigate repo",
  "research codebase", "what does this repo do", "how does this codebase work",
  "ask about repo", "codebase question", "explore repository",
  "what API does this project have", "analyze this GitHub repo",
  "explore https://github.com/...", or any request to understand a repository's
  structure, API, architecture, or implementation details. Works with both local paths
  and remote URLs (GitHub, GitLab, Bitbucket).
---

# Repo Explorer

Launch a separate Claude Code CLI process (`claude -p`) with read-only
tools to explore a repository and answer questions about it. Supports both local
repositories and remote URLs.

## Workflow

### 1. Determine repo source, question, and model

From the user's message extract:

- **source**: one of:
  - **local path** (`~/projects/foo`, `/opt/services/bar`, `.` or omitted = cwd)
  - **remote URL** (`https://github.com/owner/repo`, `[email protected]:owner/repo.git`)
  - **shorthand** (`owner/repo` — treat as `https://github.com/owner/repo`)
- **question**: what to find out about the repository.
- **model** — pick by task type, not by habit:
  - **`haiku`** — mechanical lookup, where the answer is *located* in the code and just needs
    finding: "what endpoints exist", "where is X defined", "list the migrations", structure
    inventory, "does this repo use Y".
  - **`sonnet`** — analytical work, where the answer must be *judged*, not just found: "what can we
    learn/borrow from this repo", applicability assessment, design/architecture review, comparing
    approaches, security analysis, "what's original here", trade-off summaries. Cue words: оцени,
    что полезного, идеи, применимость, review, compare, learn from.
  - A cheap model on an analytical question produces shallow results with flattened nuances that
    cost more to verify than the tokens saved — this rule exists because it happened.
  - An explicit user request ("use haiku", "запусти sonnet", opus) always overrides the heuristic.

### 2. For remote repos — clone to temp directory

If the source is a remote URL or shorthand, clone it first:

```bash
REPO_DIR=$(mktemp -d) && git clone --depth 1 <url> "$REPO_DIR" && echo "$REPO_DIR"
```

- Use `--depth 1` for speed (shallow clone, only latest commit)
- If the user asks about a specific branch/tag: `git clone --depth 1 --branch <ref> <url> "$REPO_DIR"`
- Store `$REPO_DIR` to clean up later

### 3. Run the CLI command

Use the Bash tool with **timeout: 600000** (10 min) since exploration of large repos
can take several minutes.

```
cd <repo_path> && CLAUDECODE= claude -p "<question>" \
  --model <haiku|sonnet per step 1> \
  --output-format text \
  --max-turns 15 \
  --allowedTools "Read" "Grep" "Glob" "Bash(find *)" "Bash(ls *)" "Bash(wc *)" "Bash(git log *)" "Bash(git show *)" "Bash(git diff *)" "Bash(git branch *)" "Bash(head *)" "Bash(tail *)" \
  --append-system-prompt "You are a code exploration expert. Thoroughly explore the repository to answer the user's question. Strategy: 1) Glob to discover project structure. 2) Grep to find patterns, definitions, routes, classes. 3) Read to examine key files. Always cite file paths and line numbers. Give a structured answer based on code facts."
```

**IMPORTANT:** The `CLAUDECODE=` prefix (setting the env var to empty) is required to allow
launching Claude Code as a subprocess. Without it, the nested session will be blocked.

Rules:
- **Always** include `CLAUDECODE=` directly before `claude -p` (no `&&`, it's an inline env override)
- Escape double quotes in the question with `\"`
- Wrap repo paths containing spaces in quotes
- For very large repos or analytical (sonnet) runs, increase `--max-turns` to 25
- Model follows the step 1 heuristic (haiku = lookup, sonnet = analysis); an explicit user request
  always wins

### 4. Clean up (remote repos only)

After presenting the result, remove the temp directory:

```bash
rm -rf "$REPO_DIR"
```

### 5. Present the result

Display the CLI output to the user. If empty or error, report the issue and suggest
retrying with a more specific question.

## Examples

**Local repo (lookup → haiku):**
```
cd ~/projects/my-api && CLAUDECODE= claude -p "What REST endpoints are defined? List each with HTTP method, path, and handler." --model haiku --output-format text --max-turns 15 --allowedTools "Read" "Grep" "Glob" "Bash(find *)" "Bash(ls *)" "Bash(wc *)" "Bash(git log *)" "Bash(git show *)" "Bash(git diff *)" "Bash(git branch *)" "Bash(head *)" "Bash(tail *)" --append-system-prompt "You are a code exploration expert. Thoroughly explore the repository to answer the user's question. Strategy: 1) Glob to discover project structure. 2) Grep to find patterns, definitions, routes, classes. 3) Read to examine key files. Always cite file paths and line numbers. Give a structured answer based on code facts."
```

**Remote repo (analysis → sonnet):**
```bash
REPO_DIR=$(mktemp -d) && git clone --depth 1 https://github.com/expressjs/express "$REPO_DIR"
```
Then:
```
cd "$REPO_DIR" && CLAUDECODE= claude -p "Assess the middleware chain design: what patterns are worth borrowing for our own router, and what are the known trade-offs?" --model sonnet --output-format text --max-turns 25 --allowedTools "Read" "Grep" "Glob" "Bash(find *)" "Bash(ls *)" "Bash(wc *)" "Bash(git log *)" "Bash(git show *)" "Bash(git diff *)" "Bash(git branch *)" "Bash(head *)" "Bash(tail *)" --append-system-prompt "You are a code exploration expert. Thoroughly explore the repository to answer the user's question. Strategy: 1) Glob to discover project structure. 2) Grep to find patterns, definitions, routes, classes. 3) Read to examine key files. Always cite file paths and line numbers. Give a structured answer based on code facts."
```
Then: `rm -rf "$REPO_DIR"`

**Shorthand (owner/repo):** treat `vercel/next.js` as `https://github.com/vercel/next.js`.

**Current directory (no path):** run `claude -p` without `cd`.

More from CodeAlive-AI/ai-driven-development

SkillDescription
agentic-readinessAudit and improve repositories for reliable agentic work across Codex and Codex App, Claude Code, and OpenCode. Use when reviewing AGENTS.md or CLAUDE.md quality and discovery, instruction routing in monorepos or meta-repos, agent settings, MCP configuration, skills, subagents, context budgets, or repository organization for coding agents.
agents-consiliumQuery external AI agents (Codex, Gemini, OpenCode, Claude Code headless) in parallel for independent second opinions, code review, bug investigation, and consensus on high-stakes decisions. Agents and models are configurable in config.json. Use for architecture choices, security review, or ambiguous problems where independent perspectives matter. Not for simple questions answerable from docs or the codebase — use web search or repo exploration instead.
bug-fix-protocol8-step disciplined bug-fix protocol that treats every production bug as two failures — the code defect itself and the testing system that allowed it through. Use when fixing a production bug, investigating a regression, writing a post-mortem, or auditing a missed defect. Triggers on "fix this bug", "production bug", "regression test", "post-mortem", "test gap", "why did the tests miss this".
code-that-fits-in-your-headSoftware engineering heuristics from Mark Seemann's book Code That Fits in Your Head (2021). Use when writing new code, reviewing code, refactoring, designing APIs, handling validation and invariants, writing unit tests, debugging defects, performing security review (STRIDE), or setting up a new code base. Covers decomposition (cyclomatic complexity, 80/24 rule, cohesion, fractal architecture), encapsulation (invariants, parse-don't-validate, Postel's law), outside-in TDD (walking skeleton, AAA, triangulation, devil's advocate), API design (affordance, poka-yoke, CQS), git/PR hygiene (50/72 commits, small commits, code review), feature flags, Strangler pattern, bisection debugging, logging with decorators, and STRIDE threat modelling. Not for language-specific syntax, framework tutorials, production incident response, or performance profiling.
fetch-url-as-markdownFetch a web page (URL) and return clean Markdown via local trafilatura, with Exa MCP as a fallback for JS-rendered or anti-bot pages. Use when the user asks to read, fetch, scrape, summarize, or quote a URL — prefer this over the built-in WebFetch tool. Don't use for binary files (PDFs, images, archives) or for fetching API/JSON endpoints.
fpf-problem-solvingFirst Principles Framework (FPF) — thinking amplifier. Use when user wants to think through a complex problem, architect a system, evaluate alternatives, decompose complexity, classify problems, define quality attributes, plan rigorously, apply an FPF pattern to a first useful result, decide under uncertainty, establish causality, reason about time and trends, describe or synthesize architecture, check mathematical model fit, distinguish relation kinds or occurrences, govern ontic/U-kind admission, publish multi-view artifacts, refresh SoTA packs, trace provenance, or improve pattern quality. Also triggers on: FPF, bounded contexts, SoTA packs, assurance calculus, decision theory, causal reasoning, temporal reasoning, architecture description, modularity, constraint-governed unfolding, narrative rendering, structural adequacy, cultural evolution, quality gates, lexical discipline, FPF Parts A-I. Not for simple task planning, general philosophy, or Agile unrelated to FPF.
hooks-managementManage hooks and automation for coding agents (Claude Code, Codex CLI, OpenCode). Use when users want to add, list, remove, update, or validate hooks. Triggers on requests like "add a hook", "create a hook that...", "list my hooks", "remove the hook", "validate hooks", or any mention of automating agent behavior with shell commands or plugins.
investigating-repository-historyInvestigate GitHub repository history before risky code changes using git blame/log, GitHub PRs, review comments, squash/rebase/cherry-pick/rename heuristics, and cited evidence. Use when asking why code exists, whether a change is safe, what PR introduced behavior, or before editing API, compatibility, security, concurrency, persistence, migration, or performance-sensitive code.
maintaining-macos-healthHands-on playbook for macOS disk cleanup, dev-machine optimization, and proactive health alerting. Use when the Mac is full or slow, when a process persistently burns CPU, when a kernel panic / watchdog timeout / vm-compressor-space-shortage / Jetsam event happened, when the user asks to free disk space, audit storage, set up disk/memory/CPU alerts, or restore the same monitoring on a new Mac. Built around Mole (`mo` CLI) for safety guards plus a custom LaunchAgent-based alerter for active warnings. Covers Apple Silicon laptops with heavy AI/Docker workloads. Not for general macOS support, hardware diagnostics, networking issues, GUI / window-manager bugs, Time Machine recovery, or broken app installs.
maintaining-windows-healthHands-on playbook for Windows 11 disk cleanup, dev-machine optimization, and proactive health alerting. Use when the PC is full or slow, when a BSOD / Kernel-Power 41 / crash dump / commit-memory pressure happened, when the user asks to free disk space, audit storage, set up disk/memory alerts, or restore the same monitoring on a new PC. Built around native Microsoft-supported tooling (Storage Sense, cleanmgr, DISM, pnputil, vssadmin, wevtutil, powercfg) as the safety floor, a drift-protected HTML cleanup UI, and a Task Scheduler + BurntToast alerter. Covers dev machines with heavy AI/Docker/WSL workloads. Not for general Windows support, hardware diagnostics, GPU/driver troubleshooting, antivirus/malware removal, Windows Update repair, networking, or app-specific performance problems unrelated to disk or memory pressure.