AI Tools

AI Tools¶
Context works with any AI tool that can read files. This guide covers setup for popular AI coding assistants.
Claude Code (Full Integration)¶
Claude Code has the deepest integration via the ctx plugin.
Setup¶
First, install ctx and initialize your project:
Then, install the ctx plugin in Claude Code:
# From the ctx repository
claude /plugin install ./internal/assets/claude
# Or from the marketplace
claude /plugin marketplace add ActiveMemory/ctx
claude /plugin install ctx@activememory-ctx
Ensure the Plugin Is Enabled
Installing a plugin registers it, but local installs may not
auto-enable it globally. Verify ~/.claude/settings.json contains:
Without this, the plugin's hooks and skills won't appear in other
projects. Running ctx init auto-enables the plugin; use
--no-plugin-enable to skip this step.
This gives you:
| Component | Purpose |
|---|---|
.context/ |
All context files |
CLAUDE.md |
Bootstrap instructions |
| Plugin hooks | Lifecycle automation |
| Plugin skills | Agent Skills |
How It Works¶
graph TD
A[Session Start] --> B[Claude reads CLAUDE.md]
B --> C[PreToolUse hook runs]
C --> D[ctx agent loads context]
D --> E[Work happens]
E --> F[Session End]
- Session start: Claude reads
CLAUDE.md, which tells it to check.context/ - First tool use:
PreToolUsehook runsctx agentand emits the context packet (subsequent invocations within the cooldown window are silent) - Next session: Claude reads context files and continues with context
Plugin Hooks¶
The ctx plugin provides lifecycle hooks implemented as Go subcommands
(ctx system *):
| Hook | Event | Purpose |
|---|---|---|
ctx system context-load-gate |
PreToolUse (.*) |
Auto-inject context on first tool use |
ctx system block-non-path-ctx |
PreToolUse (Bash) |
Block ./ctx or go run: force $PATH install |
ctx system qa-reminder |
PreToolUse (Bash) |
Remind agent to lint/test before committing |
ctx system specs-nudge |
PreToolUse (EnterPlanMode) |
Nudge agent to use project specs when planning |
ctx system check-context-size |
UserPromptSubmit | Nudge context assessment as sessions grow |
ctx system check-ceremonies |
UserPromptSubmit | Nudge /ctx-remember and /ctx-wrap-up adoption |
ctx system check-persistence |
UserPromptSubmit | Remind to persist learnings/decisions |
ctx system check-journal |
UserPromptSubmit | Remind to export/enrich journal entries |
ctx system check-reminders |
UserPromptSubmit | Relay pending reminders at session start |
ctx system check-version |
UserPromptSubmit | Warn when binary/plugin versions diverge |
ctx system check-resources |
UserPromptSubmit | Warn when memory/swap/disk/load hit DANGER level |
ctx system check-knowledge |
UserPromptSubmit | Nudge when knowledge files grow large |
ctx system check-map-staleness |
UserPromptSubmit | Nudge when ARCHITECTURE.md is stale |
ctx system heartbeat |
UserPromptSubmit | Session-alive signal with prompt count metadata |
ctx system post-commit |
PostToolUse (Bash) |
Nudge context capture and QA after git commits |
A catch-all PreToolUse hook also runs ctx agent on every tool use
(with cooldown) to autoload context.
Hook Configuration¶
The plugin's hooks.json wires everything automatically: no manual
configuration in settings.local.json needed:
{
"hooks": {
"PreToolUse": [
{
"matcher": ".*",
"hooks": [
{ "type": "command", "command": "ctx system context-load-gate" }
]
},
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": "ctx system block-non-path-ctx" }
]
},
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": "ctx system qa-reminder" }
]
},
{
"matcher": "EnterPlanMode",
"hooks": [
{ "type": "command", "command": "ctx system specs-nudge" }
]
},
{
"matcher": ".*",
"hooks": [
{ "type": "command", "command": "ctx agent --budget 4000 2>/dev/null || true" }
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": "ctx system post-commit" }
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{ "type": "command", "command": "ctx system check-context-size" },
{ "type": "command", "command": "ctx system check-ceremonies" },
{ "type": "command", "command": "ctx system check-persistence" },
{ "type": "command", "command": "ctx system check-journal" },
{ "type": "command", "command": "ctx system check-reminders" },
{ "type": "command", "command": "ctx system check-version" },
{ "type": "command", "command": "ctx system check-resources" },
{ "type": "command", "command": "ctx system check-knowledge" },
{ "type": "command", "command": "ctx system check-map-staleness" },
{ "type": "command", "command": "ctx system heartbeat" }
]
}
]
}
}
Customizing Token Budget and Cooldown¶
Edit the PreToolUse command to change the token budget or cooldown:
"command": "ctx agent --budget 8000 --session $PPID >/dev/null || true"
"command": "ctx agent --budget 4000 --cooldown 5m --session $PPID >/dev/null || true"
The --session $PPID flag isolates the cooldown per session: $PPID resolves
to the Claude Code process PID, so concurrent sessions don't interfere.
The default cooldown is 10 minutes; use --cooldown 0 to disable it.
Verifying Setup¶
- Start a new Claude Code session;
- Ask: "Do you remember?"
- Claude should cite specific context:
- Current tasks from
.context/TASKS.md; - Recent decisions or learnings;
- Recent session history from
ctx recall.
- Current tasks from
Local Plugin Development¶
When developing ctx locally (adding skills, hooks, or changing plugin
behavior), Claude Code caches the plugin by version. You must bump
the version in both files and update the marketplace for changes
to take effect:
- Bump version in both:
-
internal/assets/claude/.claude-plugin/plugin.json(plugin manifest),.claude-plugin/marketplace.json(marketplace listing*); -
Update the marketplace in Claude Code:
- Open the Plugins UI (
/pluginsor Esc menu), - Go to Marketplaces tab,
- Select the
activememory-ctxMarketplace, -
Choose Update marketplace;
-
Start a new Claude Code session: skill changes aren't reflected in existing sessions.
Both Version Files Must Match
If you only bump plugin.json but not marketplace.json (or
vice versa), Claude Code may not detect the update. Always bump
both together.
Troubleshooting¶
| Issue | Solution |
|---|---|
| Context not loading | Check ctx is in PATH: which ctx |
| Hook errors | Verify plugin is installed: claude /plugin list |
| New skill not visible | Bump version in both plugin.json files, update marketplace |
Manual Context Load¶
If hooks aren't working, manually load context:
Agent Skills¶
The ctx plugin ships Agent Skills following the agentskills.io specification.
These are invoked in Claude Code with /skill-name.
Session Lifecycle Skills¶
| Skill | Description |
|---|---|
/ctx-remember |
Recall project context at session start (ceremony) |
/ctx-wrap-up |
End-of-session context persistence (ceremony) |
/ctx-status |
Show context summary (tasks, decisions, learnings) |
/ctx-agent |
Get AI-optimized context packet |
/ctx-next |
Suggest 1-3 concrete next actions from context |
/ctx-commit |
Commit with integrated context capture |
/ctx-reflect |
Review session and suggest what to persist |
/ctx-remind |
Manage session-scoped reminders |
/ctx-pause |
Pause context hooks for this session |
/ctx-resume |
Resume context hooks after a pause |
Context Persistence Skills¶
| Skill | Description |
|---|---|
/ctx-add-task |
Add a task to TASKS.md |
/ctx-add-learning |
Add a learning to LEARNINGS.md |
/ctx-add-decision |
Add a decision with context/rationale/consequences |
/ctx-add-convention |
Add a coding convention to CONVENTIONS.md |
/ctx-archive |
Archive completed tasks |
Scratchpad Skills¶
| Skill | Description |
|---|---|
/ctx-pad |
Manage encrypted scratchpad entries |
Session History Skills¶
| Skill | Description |
|---|---|
/ctx-recall |
Browse AI session history |
/ctx-journal-enrich |
Enrich a journal entry with frontmatter/tags |
/ctx-journal-enrich-all |
Full journal pipeline: export if needed, then batch-enrich |
/ctx-journal-normalize |
Fix markdown rendering issues in journal |
Blogging Skills¶
Blogging is a Better Way of Creating Release Notes
The blogging workflow can also double as generating release notes:
AI reads your git commit history and creates a "narrative", which is essentially what a release note is for.
| Skill | Description |
|---|---|
/ctx-blog |
Generate blog post from recent activity |
/ctx-blog-changelog |
Generate blog post from commit range with theme |
Auditing & Health Skills¶
| Skill | Description |
|---|---|
/ctx-doctor |
Troubleshoot ctx behavior with structural health checks |
/ctx-drift |
Detect and fix context drift (structural + semantic) |
/ctx-consolidate |
Merge redundant learnings or decisions into denser entries |
/ctx-alignment-audit |
Audit doc claims against playbook instructions |
/ctx-prompt-audit |
Analyze session logs for vague prompts |
/check-links |
Audit docs for dead internal and external links |
Planning & Execution Skills¶
| Skill | Description |
|---|---|
/ctx-loop |
Generate a Ralph Loop iteration script |
/ctx-implement |
Execute a plan step-by-step with checks |
/ctx-import-plans |
Import Claude Code plan files into project specs |
/ctx-worktree |
Manage git worktrees for parallel agents |
/ctx-map |
Build and maintain architecture maps |
Usage Examples¶
/ctx-status
/ctx-add-learning "Token refresh requires explicit cache invalidation"
/ctx-journal-enrich twinkly-stirring-kettle
Skills support partial matching where applicable (e.g., session slugs).
Cursor IDE¶
Cursor can use context files through its system prompt or by reading files directly.
Setup¶
Configuration¶
Add to Cursor settings (.cursor/settings.json):
// split to multiple lines for readability
{
"ai.systemPrompt": "Read .context/TASKS.md and
.context/CONVENTIONS.md before responding.
Follow rules in .context/CONSTITUTION.md.",
}
Usage¶
- Open your project in Cursor
- Context files are available in the file tree
- Reference them in prompts: "Check .context/DECISIONS.md for our approach to..."
Manual Context Injection¶
For more control, paste context directly:
# Get AI-ready packet
ctx agent --budget 4000 | pbcopy # macOS
ctx agent --budget 4000 | xclip # Linux
Paste into Cursor's chat.
Aider¶
Aider works well with context files through its --read flag.
Setup¶
Configuration¶
Create .aider.conf.yml:
read:
- .context/CONSTITUTION.md
- .context/TASKS.md
- .context/CONVENTIONS.md
- .context/DECISIONS.md
Usage¶
# Start Aider (reads context files automatically)
aider
# Or specify files explicitly
aider --read .context/TASKS.md --read .context/CONVENTIONS.md
With Watch Mode¶
Run ctx watch alongside Aider to capture context updates:
# Terminal 1: Run Aider
aider 2>&1 | tee /tmp/aider.log
# Terminal 2: Watch for context updates
ctx watch --log /tmp/aider.log
GitHub Copilot¶
GitHub Copilot integrates with ctx at three levels: an automated
instructions file, a VS Code Chat extension, and manual patterns.
Setup¶
The --write flag creates .github/copilot-instructions.md, which
Copilot reads automatically at the start of every session. This file
contains your project's constitution rules, current tasks, conventions,
and architecture: giving Copilot persistent context without manual
copy-paste.
Re-run ctx hook copilot --write after updating your .context/ files
to regenerate the instructions.
VS Code Chat Extension (@ctx)¶
The ctx VS Code extension adds a @ctx chat participant to
GitHub Copilot Chat, giving you direct access to all context commands
from within the editor.
Installation¶
- Build from source (requires Node.js 18+):
- Install the
.vsixfile:
- Reload VS Code. Type
@ctxin Copilot Chat to verify.
Slash Commands¶
| Command | Description |
|---|---|
@ctx /init |
Initialize .context/ directory with template files |
@ctx /status |
Show context summary with token estimate |
@ctx /agent |
Print AI-ready context packet |
@ctx /drift |
Detect stale or invalid context |
@ctx /recall |
Browse and search AI session history |
@ctx /hook |
Generate AI tool integration configs |
@ctx /add |
Add a task, decision, or learning |
@ctx /load |
Output assembled context Markdown |
@ctx /compact |
Archive completed tasks and clean up |
@ctx /sync |
Reconcile context with codebase |
Usage Examples¶
@ctx /init
@ctx /status
@ctx /add task Implement user authentication
@ctx /drift
@ctx /hook copilot
@ctx /recall
Typing @ctx without a command shows help with all available commands.
The extension also supports natural language: asking @ctx about
"status" or "drift" routes to the correct command automatically.
Configuration¶
| Setting | Default | Description |
|---|---|---|
ctx.executablePath |
ctx |
Path to the ctx binary. Set this if ctx is not in your PATH. |
Follow-Up Suggestions¶
After each command, the extension suggests relevant next steps. For
example, after /init it suggests /status and /hook; after
/drift it suggests /sync.
Session Persistence¶
ctx init creates a .context/sessions/ directory for storing
session data from non-Claude tools. The Markdown session parser scans
this directory during ctx recall, enabling session history for
Copilot and other tools.
Manual Patterns¶
These patterns work without the extension, using Copilot's built-in file awareness:
Pattern 1: Keep context files open
Open .context/CONVENTIONS.md in a split pane. Copilot will reference it.
Pattern 2: Reference in comments
// See .context/CONVENTIONS.md for naming patterns
// Following decision in .context/DECISIONS.md: Use PostgreSQL
function getUserById(id: string) {
// Copilot now has context
}
Pattern 3: Paste context into Copilot Chat
Paste output into Copilot Chat for context-aware responses.
Windsurf IDE¶
Windsurf supports custom instructions and file-based context.
Setup¶
Configuration¶
Add to Windsurf settings:
// Split to multiple lines for readability
{
"ai.customInstructions": "Always read .context/CONSTITUTION.md first.
Check .context/TASKS.md for current work.
Follow patterns in .context/CONVENTIONS.md."
}
Usage¶
Context files appear in the file tree. Reference them when chatting:
- "What's in our task list?" → AI reads
.context/TASKS.md - "What convention do we use for naming?" → AI reads
.context/CONVENTIONS.md
Generic Integration¶
For any AI tool that can read files, use these patterns:
Manual Context Loading¶
# Get full context
ctx load
# Get AI-optimized packet
ctx agent --budget 8000
# Get specific file
cat .context/TASKS.md
System Prompt Template¶
You are working on a project with persistent context in .context/
Before responding:
1. Read .context/CONSTITUTION.md - NEVER violate these rules
2. Check .context/TASKS.md for current work
3. Follow .context/CONVENTIONS.md patterns
4. Reference .context/DECISIONS.md for architectural choices
When you learn something new, note it for .context/LEARNINGS.md
When you make a decision, document it for .context/DECISIONS.md
Automated Updates¶
If your AI tool outputs to a log, use ctx watch:
# Watch log file for context-update commands
your-ai-tool 2>&1 | tee /tmp/ai.log &
ctx watch --log /tmp/ai.log
The AI can emit updates like:
<context-update type="complete">implement caching</context-update>
<context-update type="learning"
context="Implementing caching layer"
lesson="Important thing learned today"
application="Apply this insight going forward"
>Caching Insight</context-update>
Context Update Commands¶
The ctx watch command parses update commands from AI output. Use this format:
Supported Types¶
| Type | Target File | Required Attributes |
|---|---|---|
task |
TASKS.md | None |
decision |
DECISIONS.md | context, rationale, consequences |
learning |
LEARNINGS.md | context, lesson, application |
convention |
CONVENTIONS.md | None |
complete |
TASKS.md | None |
Simple Format (tasks, conventions, complete)¶
<context-update type="task">Implement rate limiting</context-update>
<context-update type="convention">Use kebab-case for files</context-update>
<context-update type="complete">rate limiting</context-update>
Structured Format (learnings, decisions)¶
Learnings and decisions support structured attributes for better documentation:
Learning with full structure:
<context-update type="learning"
context="Debugging Claude Code hooks"
lesson="Hooks receive JSON via stdin, not environment variables"
application="Parse JSON stdin with the host language (Go, Python, etc.): no jq needed"
>Hook Input Format</context-update>
Decision with full structure:
<context-update type="decision"
context="Need a caching layer for API responses"
rationale="Redis is fast, well-supported, and team has experience"
consequences="Must provision Redis infrastructure; team training on Redis patterns"
>Use Redis for caching</context-update>
Learnings require: context, lesson, application attributes.
Decisions require: context, rationale, consequences attributes.
Updates missing required attributes are rejected with an error.
Further Reading¶
- Skills That Fight the Platform: Common pitfalls in skill design that work against the host tool
- The Anatomy of a Skill That Works: What makes a skill reliable: the E/A/R framework and quality gates