Skip to content

Integrate CodeGraph as native code-map provider for write-plan to reduce token/cost overhead #1951

Description

@AspirantSean

🐛 Problem Statement
When using write-plan on medium-to-large codebases, the current context retrieval strategy relies heavily on iterative grep, glob, and read tool calls to build a mental model of the codebase. This results in:
Excessive token consumption: Planning phase alone often consumes 50k–200k+ tokens due to blind scanning.
Long latency: write-plan can take 3–10 minutes before producing any output.
Unreliable plans: The model sometimes misses critical dependencies because it hit context limits during exploration.
I have manually configured CodeGraph MCP + CLAUDE.md instructions as a workaround, which reduced planning tool calls by ~90% and tokens by ~70%. However, this requires manual per-project setup and is not integrated into Superpowers' core workflow.

💡 Proposed Solution
Integrate CodeGraph (or a similar local code-graph indexing mechanism) as an optional but recommended code-map provider for write-plan:
Pre-indexing step: Add a superpowers index or auto-detect command that builds a local semantic graph of the codebase before planning.
Native integration in write-plan: When CodeGraph is available, automatically prioritize structured graph queries (query_graph, trace_call_path) over raw file scanning during the exploration phase.
Fallback mechanism: Gracefully fall back to current grep/glob behavior when CodeGraph is not installed or indexed.
CLAUDE.md auto-generation: Optionally inject CodeGraph collaboration protocol into CLAUDE.md during project initialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions