/ctx:ctx-driftfrom ctx
Detects and fixes context drift in Claude Code context files — structural (stale paths, broken references) via CLI and semantic (outdated conventions, superseded decisions) via agent analysis.
Ships in ctx. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Detect context drift at two layers: structural (stale paths,
missing files, constitution violations) via ctx drift, and
semantic (outdated conventions, superseded decisions,
irrelevant learnings) via agent analysis. The semantic layer is
where the real value is: the CLI cannot do it.
/ctx-status and everything looked fine
(status already shows drift warnings)/ctx-drift
/ctx-drift (after the refactor)
Drift detection has two layers: structural (programmatic) and semantic (agent-driven). Always do both.
Run the CLI tool for fast, programmatic checks:
ctx drift
This catches dead paths, missing files, staleness indicators, and constitution violations. These are necessary but insufficient: they only detect structural problems.
After the structural check, read the context files yourself and compare them to what you know about the codebase. This is where you add real value: the CLI tool cannot do this.
Check for:
After both layers, do not dump raw output. Instead:
ctx drift --fix to clean up the dead path
references. Want me to?"ctx syncctx compact --archive| Finding | What It Means | Suggested Action |
|---|---|---|
| Path does not exist | Context references a deleted file/dir | Remove reference or update path |
| Directory is empty | Referenced dir exists but has no files | Remove reference or populate directory |
| Many completed tasks | TASKS.md is cluttered | Run ctx compact --archive |
| File not modified in 30+ days | Content may be outdated | Review and update or confirm current |
| Constitution violation | A hard rule may be broken | Fix immediately |
| Missing packages | An internal/ package is not in ARCHITECTURE.md | Add it with /ctx-architecture or document manually |
| Required file missing | A core context file does not exist | Create it with ctx init or manually |
When the user agrees to auto-fix:
ctx drift --fix
After fixing, run ctx drift again to confirm remaining
issues need manual attention. Report what was fixed and what
still needs the user's judgment.
After running ctx drift, check whether the project's
installed skills (.claude/skills/) match the canonical
templates shipped with ctx.
Create a temp directory and run ctx init --reset inside
it to get the latest templates:
CTX_TPL_DIR=$(mktemp -d)
cd "$CTX_TPL_DIR" && ctx init --reset 2>/dev/null
Compare each skill in the project against the template:
diff -ru "$CTX_TPL_DIR/.claude/skills/" .claude/skills/ 2>/dev/null
Clean up the temp directory:
rm -rf "$CTX_TPL_DIR"
| Finding | Action |
|---|---|
| Skill missing from project | Offer to install: copy from template |
| Skill differs from template | Show the diff; offer to update to latest template |
| Project has extra skills (no match) | These are custom: leave them alone |
| No differences | Skills are up to date; report clean |
When reporting skill drift, distinguish between:
If a skill was intentionally customized, note it and move on. Offer to update only ctx-managed skills, and always show the diff before overwriting.
After checking skills, verify that .claude/settings.local.json
has the expected ctx permissions. This file is gitignored, so it
drifts independently from the codebase.
Read .claude/settings.local.json and extract the allow list.
Check for missing ctx defaults. Every entry in
DefaultAllowPermissions() (defined in
internal/assets/permissions/allow.txt) should be present. The current
expected set is:
Bash(ctx:*): covers all ctx subcommandsSkill(ctx-*): one entry per ctx-shipped skillTo get the authoritative list:
ctx init --reset 2>/dev/null # in a temp dir
Then compare permissions from the generated
settings.local.json against the project's copy.
Check for stale skill permissions. If a Skill(ctx-*)
entry references a skill that no longer exists in
.claude/skills/, flag it.
Check for missing skill permissions. If a ctx-* skill
exists in .claude/skills/ but has no corresponding
Skill(ctx-*) in the allow list, flag it.
| Finding | Action |
|---|---|
Missing Bash(ctx:*) | Suggest adding: required for ctx to work |
Missing Skill(ctx-*) entry | Suggest adding: skill will prompt every time |
Stale Skill(ctx-*) entry | Suggest removing: dead reference |
Granular Bash(ctx <sub>:*) | Suggest consolidating to Bash(ctx:*) |
| One-off / session debris entries | Note as hygiene issue (see docs/operations/runbooks/sanitize-permissions.md) |
Do not edit settings.local.json directly. Report findings
and let the user make changes. This file controls agent
permissions: self-modification is a security concern. Refer
users to docs/operations/runbooks/sanitize-permissions.md for the manual cleanup
procedure.
Run drift detection without being asked when:
When running proactively, keep the report brief:
I ran a quick drift check after the refactor. Two stale path references in ARCHITECTURE.md. Want me to clean them up?
After running drift detection, verify:
--fix without user confirmationWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub activememory/ctx --plugin ctx54 skills in this plugin
/ctx-agentLoad full context packet. Use at session start or when context seems stale or incomplete./ctx-architectureBuild and maintain architecture maps. Use to create or refresh ARCHITECTURE.md and DETAILED_DESIGN.md. Supports principal mode for deeper analysis: vision, future direction, bottlenecks, implementation alternatives, gaps, upstream proposals, and intervention points./ctx-architecture-enrichEnrich architecture artifacts with code intelligence data. Takes existing /ctx-architecture output as baseline, verifies and quantifies with GitNexus MCP (blast radius, execution flows, domain clustering, registration sites). Run after /ctx-architecture, not instead of it./ctx-architecture-failure-analysisAdversarial failure analysis for codebases. Generates falsifiable incident hypotheses: race conditions, ordering assumptions, cache staleness, error swallowing, ownership gaps, idempotency failures, and scaling cliffs. Produces DANGER-ZONES.md with evidence-backed, ranked findings./ctx-archiveArchive completed tasks. Use when TASKS.md has many completed items cluttering the view./ctx-blogGenerate blog post draft. Use when documenting project progress, sharing learnings, or writing about development experience.Other plugins' skills for the same job