claude-code - 💡(How to fix) Fix GSD: auto-remap codebase after significant phase execution [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45369Fetched 2026-04-09 08:07:01
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1labeled ×1

Discovered after Phase 20 (Chart of Accounts + Journal Engine) added:

  • 2 new API route modules
  • 4 new domain functions
  • 2 new shared schemas
  • 1 new DB schema file (4 tables)
  • 6 new frontend feature files
  • 1 new migration

The .planning/codebase/ maps from 2 days prior had zero awareness of any of it.

Error Message

  • Warn the user: "Phase 20 added 6 new structural elements. Run /gsd-map-codebase to update planning context."

Root Cause

Discovered after Phase 20 (Chart of Accounts + Journal Engine) added:

  • 2 new API route modules
  • 4 new domain functions
  • 2 new shared schemas
  • 1 new DB schema file (4 tables)
  • 6 new frontend feature files
  • 1 new migration

The .planning/codebase/ maps from 2 days prior had zero awareness of any of it.

RAW_BUFFERClick to expand / collapse

Problem

After executing a phase that adds significant new code (new packages, route modules, DB schema domains, frontend feature directories), the .planning/codebase/ mapping files go stale silently. Future planning agents then work from an outdated structural picture, leading to:

  • Plans that miss existing patterns/conventions in new code
  • Verification steps that don't know about new integration boundaries
  • Research phases that rediscover what's already built

Currently, codebase mapping (/gsd-map-codebase) is a manual one-time setup step. There's no post-phase hook to detect structural drift.

Proposed Solution

Add a structural drift check at the end of the execute-phase workflow (or verify-work), after all plans complete:

  1. Compare committed files against .planning/codebase/STRUCTURE.md to detect:

    • New directories outside existing mapped paths
    • New barrel exports in packages/*/src/index.ts or apps/*/src/index.ts
    • New migration files (migration count changed)
    • New route modules registered in app entry points
  2. If drift exceeds a threshold (e.g., 3+ new structural elements), either:

    • Auto-trigger a targeted remap of affected areas (preferred)
    • Warn the user: "Phase 20 added 6 new structural elements. Run /gsd-map-codebase to update planning context."
  3. The remap could be incremental — only re-analyze changed packages/apps rather than full codebase scan.

Context

Discovered after Phase 20 (Chart of Accounts + Journal Engine) added:

  • 2 new API route modules
  • 4 new domain functions
  • 2 new shared schemas
  • 1 new DB schema file (4 tables)
  • 6 new frontend feature files
  • 1 new migration

The .planning/codebase/ maps from 2 days prior had zero awareness of any of it.

Alternatives

  • Post-phase git diff summary that flags "these paths are outside mapped structure"
  • A stale_since field in each codebase map file, auto-bumped when mapped paths change

extent analysis

TL;DR

Implement a structural drift check at the end of the execute-phase workflow to detect changes in the codebase and trigger an update of the .planning/codebase/ mapping files.

Guidance

  • Add a post-phase hook to the execute-phase workflow to compare committed files against the .planning/codebase/STRUCTURE.md file and detect structural changes such as new directories, barrel exports, migration files, and route modules.
  • If structural drift is detected, consider auto-triggering a targeted remap of affected areas or warning the user to run /gsd-map-codebase to update the planning context.
  • To mitigate the issue, consider implementing an incremental remap that only re-analyzes changed packages and apps rather than performing a full codebase scan.
  • Evaluate the proposed solution's threshold for detecting structural drift (e.g., 3+ new structural elements) and adjust as needed to balance between automated updates and user intervention.

Example

No code snippet is provided as the issue does not contain specific code examples.

Notes

The proposed solution assumes that the execute-phase workflow and /gsd-map-codebase command are already implemented and functional. The effectiveness of the solution depends on the accuracy of the structural drift detection and the threshold set for triggering updates.

Recommendation

Apply the proposed workaround by adding a structural drift check to the execute-phase workflow, as it provides a targeted solution to the problem of stale .planning/codebase/ mapping files. This approach allows for automated detection and update of structural changes, reducing the likelihood of plans missing existing patterns and conventions in new code.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING