Get the FREE Ultimate OpenClaw Setup Guide →

maintaining-project-context

npx machina-cli add skill ed3dai/ed3d-plugins/maintaining-project-context --openclaw
Files (1)
SKILL.md
6.8 KB

Maintaining Project Context

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

Core Principle

Context files (CLAUDE.md or AGENTS.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.

Format Detection (MANDATORY FIRST STEP)

Before any updates, detect what format this repository uses:

# Check for AGENTS.md at root
ls -la AGENTS.md 2>/dev/null

# Check for CLAUDE.md at root
ls -la CLAUDE.md 2>/dev/null
Root AGENTS.md?FormatAction
YesAGENTS.md-canonicalUpdate AGENTS.md files, create companion CLAUDE.md
NoCLAUDE.md-canonicalUpdate CLAUDE.md files directly

Key principle: We use OUR format structure (Purpose, Contracts, Dependencies, Invariants, etc.) regardless of filename. AGENTS.md is just for cross-platform AI agent compatibility.

AGENTS.md-Canonical Repos

When the repo uses AGENTS.md:

  1. Read AGENTS.md first before making any updates
  2. Write content to AGENTS.md using our standard structure
  3. Create companion CLAUDE.md next to each AGENTS.md with exactly this content:
Read @./AGENTS.md and treat its contents as if they were in CLAUDE.md

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 context file
New domain<domain>/ context file (create)
Existing domain contract<domain>/ context file (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.

For AGENTS.md-canonical repos: When creating new domain context files, create both AGENTS.md (with content) and CLAUDE.md (companion pointer).

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 (especially for AGENTS.md)
  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 (CLAUDE.md-canonical repos):

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

For new domains (AGENTS.md-canonical repos):

  1. Create <domain>/AGENTS.md using template from writing-claude-md-files
  2. Document purpose, contracts, dependencies, invariants
  3. Set freshness date
  4. Create companion <domain>/CLAUDE.md:
    Read @./AGENTS.md and treat its contents as if they were in CLAUDE.md
    

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 → Detect format first (AGENTS.md at root?)
    │
    └─ What changed?
        ├─ Only tests/internal details → Skip
        └─ Contracts/APIs/structure → Continue
            │
            ├─ New domain created?
            │   ├─ AGENTS.md repo → Create AGENTS.md + companion CLAUDE.md
            │   └─ CLAUDE.md repo → Create CLAUDE.md
            │
            ├─ Existing domain changed?
            │   └─ Update domain context file (read first!)
            │
            └─ Project-wide pattern changed?
                └─ Update root context file

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
Skipping format detectionAlways check for AGENTS.md first
Writing AGENTS.md without readingAlways read existing content before updating
Forgetting companion CLAUDE.mdAGENTS.md repos need both files

Integration Points

Called by:

  • project-claude-librarian agent - Uses this skill to coordinate updates
  • executing-an-implementation-plan (Step 5b) - After all tasks complete
  • finishing-a-development-branch (Step 4b) - Before merge/PR

Uses:

  • writing-claude-md-files - For actual context file creation/updates (works for both CLAUDE.md and AGENTS.md)

Source

git clone https://github.com/ed3dai/ed3d-plugins/blob/main/plugins/ed3d-extending-claude/skills/maintaining-project-context/SKILL.mdView on GitHub

Overview

Maintaining Project Context ensures documentation stays aligned with code changes by updating CLAUDE.md or AGENTS.md when contracts, APIs, or domain structures shift. It analyzes what changed, determines affected contracts and documentation, and coordinates updates to reflect the current architecture and intent. The skill relies on a required sub-skill for creating and updating the MD files.

How This Skill Works

At trigger points (end of development, branch completion, or contract changes), it first detects repository format by checking for AGENTS.md or CLAUDE.md. It then diffs the base and current HEAD to categorize changes (structural, contract, behavioral, internal) and maps each change to the appropriate context file. Finally it updates or creates context files and verifies the contracts, dependencies, and invariants, using the ed3d-extending-claude:writing-claude-md-files sub-skill for content generation.

When to Use It

  • End of development phase or branch completion
  • New domain or module introduction
  • API/interface changes requiring documentation updates
  • Architectural decisions affecting contracts or invariants
  • Changes to dependencies or cross-domain relationships

Quick Start

  1. Step 1: Detect repo format (AGENTS.md vs CLAUDE.md) and run git diff to identify changes
  2. Step 2: Map each change to the appropriate context file, preferring domain-level updates when possible
  3. Step 3: Update or create context files and verify Contracts, Dependencies, and Invariants; use ed3d-extending-claude:writing-claude-md-files for content creation

Best Practices

  • Run a diff against the base to identify changed files and categorize changes
  • Document changes at the lowest applicable domain level (domain-specific first)
  • Verify Contracts, Dependencies, and Invariants reflect current code
  • Create companion CLAUDE.md when working in AGENTS.md-canonical repos
  • Use the required sub-skill for all context file creation and updates

Example Use Cases

  • A new payments module is added; update root CLAUDE.md and create a payments domain context file with contracts and dependencies.
  • User service API surface changes; update the Contracts section in CLAUDE.md and adjust related Dependencies.
  • Architectural decision to adopt event-driven messaging; document the decision in AGENTS.md and link it to CLAUDE.md.
  • Invariant changes in authentication flow; update the Invariants section across relevant domain context files.
  • Dependency change where shipping depends on new orders API; update both domain context files to reflect new uses and boundaries.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers