Skip to content

Generating context files

Not every AI tool speaks MCP. Many just read a file at startup — CLAUDE.md, .cursorrules, .windsurfrules, AGENTS.md, .github/copilot-instructions.md. dim generate-context turns your trusted memory into exactly those files, so every assistant benefits, MCP or not.

Context files are opt-in

By default, aiDimag does not automatically generate or update these files. You must explicitly run dim generate-context (or enable --auto mode) to create them. This means:

  • dim init does not create context files
  • dim review approving memories does not update context files
  • dim mine or dim bootstrap do not generate context files

Use --auto (explained below) to enable automatic regeneration.

Generate the files

sh
dim generate-context                 # writes CLAUDE.md
dim generate-context -f cursorrules  # .cursorrules (Cursor)
dim generate-context -f copilot      # .github/copilot-instructions.md
dim generate-context -f windsurfrules # .windsurfrules (Windsurf)
dim generate-context -f agents       # AGENTS.md (cross-tool standard)
dim generate-context -f all          # all five at once

Output:

📝 Wrote CLAUDE.md, .cursorrules, .windsurfrules, AGENTS.md, .github/copilot-instructions.md — 12 memories (3 pinned).

What goes in (and what doesn't)

  • Included: verified and unverified memories, with pinned ones leading.
  • Excluded: stale and refuted memories — tools never see knowledge you can't currently trust.
  • Ordered by signal: guardrails first, then decisions, conventions, invariants, architecture, gotchas, skills, failed approaches, open context.

A generated CLAUDE.md looks like:

md
# Project Memory
> Auto-generated by aidimag · 12 memories, 3 pinned

Treat the items below as the project's verified beliefs. Respect every Guardrail:
🚫 NEVER = refuse and explain why · ✅ ALWAYS = do it without asking · 🤚 ASK FIRST = check first.

## Guardrails ⚠️
- 🚫 NEVER: Never call the production payments API from src... [VERIFIED 📌]

## Conventions
- All DB access goes through src/db/store.ts (scope: src/db) [VERIFIED]

## Skills (reusable procedures)
- **Deploy**
  1. run tests
  2. bump version
  ...

Don't edit generated files by hand

The header says so for a reason — dim generate-context overwrites them. Edit the memory (dim remember, dim review), then regenerate.

Keep them fresh automatically

Run it once with --auto and aiDimag regenerates the files whenever your trusted memory changes — after dim verify, dim review, or dim sync:

sh
dim generate-context --auto          # turn auto-refresh ON (saved in config)
dim generate-context --auto -f all   # auto-refresh all three formats
dim generate-context --no-auto       # turn it OFF

With auto on, a dim verify that flips a memory's status prints:

(regenerated CLAUDE.md — 12 memories)

So your spec self-heals: when the verifier changes what the project believes, the context every AI tool reads updates with zero manual steps.

For most repos:

sh
dim generate-context --auto -f all

Generated files are gitignored by default

When you run dim init, all generated context files (CLAUDE.md, .cursorrules, .windsurfrules, AGENTS.md, .github/copilot-instructions.md) are automatically added to .gitignore.

To commit them to git: Remove them from .gitignore if you want teammates' non-MCP tools to pick them up from git. Otherwise, each person generates locally with --auto.

Next: Pre-commit checks.

Licensed under Elastic License 2.0 — free for teams of 10 or fewer users.