Skip to content

Replace hot-context managed block in CLAUDE.md/AGENTS.md with @import lines (single source of truth, kills drift footgun) #1119

Description

@waleedkadous

Summary

Replace the materialized hot-context managed block in CLAUDE.md / AGENTS.md with Claude Code @import lines pointing at the hot files. Today the block inlines a verbatim copy of codev/resources/arch-critical.md + lessons-critical.md into both root docs — three copies of the same content (source + CLAUDE.md + AGENTS.md), a DRY violation, with a real drift footgun: edit a hot file, forget codev update, and the committed block silently goes stale (no test/doctor guard catches it).

Claude Code expands @path imports into context at session launch (transcluded, always-on — not lazy), so two import lines give the same always-on guarantee with a single source of truth and no copy to drift.

Decision is locked (maintainer): use @import. Do NOT add a drift-check, and do NOT worry about whether non-Claude AGENTS.md tools expand @import — out of scope.

Prescribed implementation

  1. lib/managed-block.tsrenderHotContextBlock: emit the two import lines instead of inlining file contents:
    @codev/resources/arch-critical.md
    @codev/resources/lessons-critical.md
    
    • Keep the existing <!-- BEGIN/END CODEV HOT CONTEXT --> markers around them. This is deliberate: it preserves the idempotent upsertHotContextBlock, so an existing adopter's old inlined block is auto-migrated to the @import form on their next codev init/codev update.
    • Keep the "generated — do not edit; edit the hot files" comment + the short intro lines.
    • Keep returning '' when neither hot file resolves (callers leave the doc untouched).
    • Only import a given file if it resolves (don't emit an @import for a hot file that isn't present).
  2. Keep copyHotTierDefaults materializing the hot files into codev/resources/ on init/adopt/update, and keep them user-data-protected — the @import only resolves if the file is on disk at that path. Paths are relative to the importing doc's dir (repo root), so @codev/resources/... is correct for both our repo and adopters.
  3. Do NOT change porch injection. commands/porch/prompts.ts (readHotTierFiles → inline) must keep inlining the live hot content: porch prompts go straight to the model (consult/agent SDK), which does NOT expand @import. That path is already DRY-safe (reads source live) — leave it.
  4. Regenerate our own root docs: run the updated sync so CLAUDE.md + AGENTS.md carry the @import block; keep them byte-identical (governance-sweep invariant).
  5. Mirror in BOTH trees + all templates: codev/ and codev-skeleton/, plus the six template docs ({codev-skeleton,codev,packages/codev/skeleton}/templates/{CLAUDE,AGENTS}.md). Grep both trees before claiming done.
  6. Tests: update managed-block.test.ts + hot-tier-materialization.test.ts so the rendered block asserts the @import lines (and NOT the inlined hot content); add a case proving an old inlined block upserts to the @import form (adopter migration). governance-sweep.test.ts marker checks stay.

Out of scope

Drift-detection tooling; AGENTS.md non-Claude @import support; cold-tier (arch.md/lessons-learned.md) changes; porch injection changes.

Acceptance

  • CLAUDE.md / AGENTS.md (both trees + all six templates) contain the two @codev/resources/*-critical.md @import lines inside the managed markers, and no verbatim copy of the hot content.
  • codev update migrates a pre-existing inlined block to the @import form (idempotently).
  • Porch phase prompts still inline the live hot content (unchanged).
  • Our CLAUDE.md and AGENTS.md remain byte-identical. Full suite green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/scaffoldArea: Install path — codev init/adopt/update/doctor, codev-skeleton, four-tier resolver

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions