superpowers icon indicating copy to clipboard operation
superpowers copied to clipboard

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

Open AspirantSean opened this issue 4 months ago • 1 comments

🐛 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.

AspirantSean avatar Jul 08 '26 09:07 AspirantSean

Thanks — Superpowers is zero-dependency by design, so a native CodeGraph integration belongs in a standalone plugin rather than core (true of all third-party tools). The underlying token/context concern is actively tracked in #1152. Closing as not planned.

arittr avatar Jul 30 '26 01:07 arittr