Research codebase

From coalesce-labs/catalyst · View interactive version

Research codebase is an AI agent skill from the GitHub repository coalesce-labs/catalyst. Conduct comprehensive codebase research using parallel sub-agents. **ALWAYS use when** the user asks to 'research', 'investigate', 'explore the codebase', 'how does X work', 'find out about', or needs deep analysis of how existing code is structured. Produces a research document in thoughts/shared/r

How to use this skill

Skill file

Research Codebase

You are tasked with conducting comprehensive research across the codebase to answer user questions by spawning parallel sub-agents and synthesizing their findings.

You are a documentarian, not a critic. Document what EXISTS without suggesting improvements, critiquing implementation, or proposing changes unless the user explicitly asks.

CRITICAL REQUIREMENTS — read these before doing anything else:

  1. You MUST save a research document to thoughts/shared/research/YYYY-MM-DD-description.md
  2. Do NOT save to memory, personal notes, or any other location
  3. Do NOT use the EnterPlanMode tool, create plans, or start implementing
  4. Your job ends when the research document is written and synced to thoughts/

Paths. Commands below name files inside this skill's own directory as ${CLAUDE_SKILL_DIR}/…. Claude Code fills that in. On any other harness, set CLAUDE_SKILL_DIR to the absolute directory that contains this SKILL.md before running them. If you cannot, stop and report skill_dir_unresolved.

Prerequisites

# Thoughts must exist for this skill's documents. CTL-2306: the full host setup check (daemon,
# registry, house rules) belongs to the setup-catalyst skill, not to a skill that must run anywhere.
[[ -e thoughts/shared ]] || echo "⚠️ thoughts/shared is missing in $(pwd) — run \`humanlayer thoughts init\` or the setup-catalyst skill; if the prompt names an output path, write there" >&2

Session Tracking

# Session tracking uses the installed catalyst-session CLI when this host has one; skipped otherwise.
SESSION_SCRIPT="$(command -v catalyst-session 2>/dev/null || true)"
if [[ -n "$SESSION_SCRIPT" ]]; then
  CATALYST_SESSION_ID=$("$SESSION_SCRIPT" start --skill "research-codebase" \
    --ticket "${TICKET_ID:-}" \
    --workflow "${CATALYST_SESSION_ID:-}")
  export CATALYST_SESSION_ID
fi

Initial Setup

When this command is invoked, respond with:

I'm ready to research the codebase. Please provide your research question or area of interest,
and I'll analyze it thoroughly by exploring relevant components and connections.

Then wait for the user's research query.

Pull-Before-Read (CTL-1236)

Before the first thoughts read, fast-forward the HumanLayer thoughts checkouts so research picks up the freshest peer state. Fast-forward only and non-fatal; it runs through the installed thoughts-pull-sync CLI when this host has one and is skipped otherwise:

# Pull-before-read (CTL-1236): ff-only, non-fatal, host tooling — never a dependency of the research.
if command -v thoughts-pull-sync >/dev/null 2>&1; then thoughts-pull-sync >/dev/null 2>&1 || true; fi

Steps to Follow After Receiving the Research Query

Step 0: Orient with Serena (ALWAYS attempt this first)

Before reading files or spawning sub-agents, get a fast semantic map of the codebase from Serena — Catalyst's self-hosted, local code-understanding MCP (the DeepWiki replacement). This is free and usually answers "where does X live / how is Y wired" in one call instead of many Greps, so your sub-agent prompts come out specific rather than exploratory.

Prerequisite check — only do this if the mcp__serena__* tools are available (Serena MCP is installed). If they are not, skip straight to Step 1 — do not retry or warn the user.

  1. Activate the project so the language servers target this repo: mcp__serena__activate_project with the repo root (the current working directory, or .).
  2. Read the persisted orientation: mcp__serena__list_memories, then mcp__serena__read_memory("codebase_map") for the directory map and key concepts.
  3. Map the relevant area instead of broad grepping: mcp__serena__get_symbols_overview on a key file, mcp__serena__find_symbol to jump to a definition, and mcp__serena__find_referencing_symbols to see its callers.

Serena's results are a starting point — always verify against live code via the sub-agents below.

Step 1: Read any directly mentioned files first

Step 2: Analyze and decompose the research question

Step 3: Spawn parallel sub-agent tasks for comprehensive research

Create multiple Task agents to research different aspects concurrently.

Specialized agents available:

Each agent's instructions ship with this skill as ${CLAUDE_SKILL_DIR}/assets/agents/<name>.md (for example ${CLAUDE_SKILL_DIR}/assets/agents/codebase-locator.md). With the catalyst-dev Claude Code plugin, spawn them as catalyst-dev:<name>. On any other harness, spawn a general-purpose subagent with that file's instructions plus your request, or do the task inline if the harness has no subagents.

The key is to use these agents intelligently:

After spawning agents, record the phase transition:

if [[ -n "${CATALYST_SESSION_ID:-}" && -x "$SESSION_SCRIPT" ]]; then
  "$SESSION_SCRIPT" phase "$CATALYST_SESSION_ID" "researching" --phase 1
fi

Step 4: Wait for all sub-agents to complete and synthesize findings

Step 5: Gather metadata for the research document

Collect metadata using git commands:

Document location: thoughts/shared/research/YYYY-MM-DD-{ticket}-{description}.md

IMPORTANT: Document Storage Rules

Step 6: Generate research document

Create a structured research document:

---
date: YYYY-MM-DDTHH:MM:SS+TZ
researcher: { your-name }
git_commit: { commit-hash }
branch: { branch-name }
repository: { repo-name }
topic: "{User's Research Question}"
tags: [research, codebase, { component-names }]
status: complete
last_updated: YYYY-MM-DD
last_updated_by: { your-name }
type: research
source_ticket: { TICKET-ID or null }
---

# Research: {User's Research Question}

**Date**: {date/time with timezone} **Researcher**: {your-name} **Git Commit**: {commit-hash} **Branch**: {branch-name} **Repository**: {repo-name}

## Research Question

{Original user query, verbatim}

## Summary

{High-level documentation of what you found. 2-3 paragraphs explaining the current state of the system in this area. Focus on WHAT EXISTS, not what should exist.}

## Detailed Findings

### {Component/Area 1}

**What exists**: {Describe the current implementation}

- File location: `path/to/file.ext:123`
- Current behavior: {what it does}
- Key functions/classes: {list with file:line references}

**Connections**: {How this component integrates with others}

### {Component/Area N}

{Continue for all major findings}

## Code References

- `path/to/file1.ext:123-145` - {What this code does}
- `path/to/file2.ext:67` - {What this code does}

## Architecture Documentation

{Document current architectural patterns and data flow. Descriptive, not prescriptive.}

## Historical Context (from thoughts/)

{Include insights from thoughts/ documents that provide context, if applicable}

## Open Questions

{Areas that would benefit from further investigation}

## Related Documents

{List related thoughts documents using wiki-links, e.g.:}

- [[YYYY-MM-DD-source-ticket|Source Ticket]]
- [[YYYY-MM-DD-related-research|Related Research]]

Step 7: Add GitHub permalinks (if applicable)

Step 8: Sync, track, and present findings

MANDATORY — do all three sub-steps before presenting results to the user.

8a. Sync thoughts:

humanlayer thoughts sync

8b. Linear comment (if ticket detected): Add a comment noting research is complete and linking the document path. Use Linearis CLI (run linearis comments usage for syntax). Skip this when CATALYST_PHASE is set — the runner publishes the phase outcome to the ticket itself. If Linearis CLI is not available, skip silently and continue.

8e. Present summary to user:

Research complete!

**Research document**: {exact file path you wrote}

**Summary**: {2-3 sentence summary}

**Key files**: {Top 3-5 file references}

Would you like me to:
1. Dive deeper into any specific area?
2. Explore related topics?

End session tracking:

if [[ -n "${CATALYST_SESSION_ID:-}" && -x "$SESSION_SCRIPT" ]]; then
  "$SESSION_SCRIPT" end "$CATALYST_SESSION_ID" --status done
fi

STOP HERE. Do NOT offer to create plans, use EnterPlanMode, or start implementing. Research is complete.

Step 9: Handle follow-up questions

If the user has follow-up questions:

Important Notes

Linear Integration

State names (stateMap.*) come from the linearis skill's single-source transition table — not restated here.

If a ticket is detected (provided as argument, mentioned in query, or from context):

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.