Skip to content
maintaining-project-context logo

Maintaining Project Context

maintaining-project-context

Use when completing development phases or branches to identify and update CLAUDE.md files that may have become stale - analyzes what changed, determines affected contracts and documentation, and coordinates updates

SKILL.md

Full skill instructions

Maintaining Project Context

REQUIRED SUB-SKILL: Use writing-claude-md-files for all context file creation and updates.

Core Principle

Context files (CLAUDE.md) document contracts and architectural intent. When code changes contracts, the documentation must update. Stale documentation is worse than no documentation.

Trigger: End of development phase, branch completion, or any work that changed contracts, APIs, or domain structure.

When to Update Context Files

Change TypeUpdate Required?What to Update
New domain/​moduleYesCreate domain context file
API/​interface changeYesContracts section
Architectural decisionYesKey Decisions section
Invariant changeYesInvariants section
Dependency changeYesDependencies section
Bug fix (no contract change)No-
Refactor (same behavior)No-
Test additionsNo-

The Process

Step 1: Identify What Changed

Diff against the base (branch start or phase start):

# Get changed files
git diff --name-only <base-sha> HEAD

# Get detailed changes
git diff <base-sha> HEAD --stat

Categorize changes:

  • Structural: New directories, moved files
  • Contract: Changed exports, interfaces, public APIs
  • Behavioral: Changed invariants, guarantees
  • Internal: Implementation details only

Step 2: Map Changes to Context Files

For each significant change, determine which context file should document it:

Change LocationContext File Location
Project-wide patternRoot CLAUDE.md
New domain<domain>/​CLAUDE.md (create)
Existing domain contract<domain>/​CLAUDE.md (update)
Cross-domain dependencyBoth affected domains

Hierarchy rule: Information belongs at the lowest level where it applies. Domain-specific contracts go in domain files, not root.

Step 3: Verify Contracts Still Hold

For each affected context file, verify:

  1. Contracts section: Do exposes/​guarantees/​expects match current code?
  2. Dependencies section: Are uses/​used-by/​boundary accurate?
  3. Invariants section: Are all invariants still enforced?
  4. Key Decisions section: Any new decisions to document?
# Find domain's public exports
grep -r "export" <domain>/​index.ts

# Find domain's imports (dependencies)
grep -r "from '\.\." <domain>/

Step 4: Update or Create Context Files

For updates:

  1. Read existing file first
  2. Update freshness date via date +%Y-%m-%d
  3. Update affected sections
  4. Remove stale content
  5. Verify under token budget (<100 lines for domain files)

For new domains:

  1. Create <domain>/​CLAUDE.md using template from writing-claude-md-files
  2. Document purpose, contracts, dependencies, invariants
  3. Set freshness date

Step 5: Commit Documentation Updates

git add <affected CLAUDE.md files>
git commit -m "docs: update project context for <branch-name>"

Decision Tree

Has code changed?
├─ No → Skip (nothing to update)
└─ Yes → What changed?
    ├─ Only tests/​internal details → Skip
    └─ Contracts/​APIs/​structure → Continue
        │
        ├─ New domain created?
        │   └─ Create CLAUDE.md
        │
        ├─ Existing domain changed?
        │   └─ Update domain CLAUDE.md
        │
        └─ Project-wide pattern changed?
            └─ Update root CLAUDE.md

Quick Reference

Always update when:

  • New public exports added
  • Interface signatures changed
  • Invariants added/​removed
  • Dependencies changed
  • Architectural decisions made

Never update for:

  • Internal refactoring
  • Bug fixes that don't change contracts
  • Test file changes
  • Comment/​documentation-only changes

Common Mistakes

MistakeFix
Updating for every changeOnly update for contract changes
Forgetting freshness dateAlways use date +%Y-%m-%d
Documenting implementationDocument contracts and intent
Putting domain info in rootUse domain context files for domain contracts
Skipping verificationRead the code, confirm contracts hold

Integration Points

Called by:

  • project-claude-librarian agent - Uses this skill to coordinate updates
  • executing-plans - After all tasks complete
  • finishing-a-development-branch - Before merge/​PR

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View