ctx
View and manage hierarchical context for the current directory
When & Why to Use This Skill
The ctx skill is a sophisticated hierarchical context management tool designed to optimize AI agent performance by providing structured, multi-level instructions. It dynamically aggregates context from local directories, repository roots, and global user settings, ensuring that the AI always operates with the most relevant coding standards, architectural patterns, and project-specific rules. By utilizing inheritance and override mechanisms, it prevents instruction drift and maintains consistency across complex codebases.
Use Cases
- Enforcing directory-specific coding conventions in large-scale monorepos while inheriting global project standards.
- Managing architectural constraints and design patterns that vary between different modules or microservices within a single repository.
- Streamlining AI agent onboarding by providing a clear hierarchy of 'source of truth' documentation from the user level down to the feature level.
- Using the @override and @ignore directives to customize AI behavior for legacy code sections or experimental sub-projects without affecting the main codebase.
- Visualizing the resolved context tree to debug and audit the specific instructions being fed to the AI agent at any given directory depth.
| name | ctx |
|---|---|
| description | View and manage hierarchical context for the current directory |
| user_invocable | true |
/ctx - Hierarchical Context Viewer
Shows the resolved context for the current working directory, aggregated from all levels of the hierarchy.
Usage
/ctx # Show resolved context
/ctx tree # Show context hierarchy as tree
/ctx edit # Edit context at current scope
What This Shows
Context is resolved by walking up from the current directory:
- Feature/Component level -
.context/CONTEXT.mdin current or parent dirs - Repo level -
.claude/CONTEXT.mdat repository root - Project level - Context above the repo
- User level -
~/.claude/CONTEXT.mdfor global preferences
Each level can:
- Inherit from parent (default)
- Override specific sections with
@override: section_name - Ignore parent sections with
@ignore: section_name
Implementation
When invoked, run:
python3 ~/.claude/plugins/agent-swarm/ctx/resolver.py resolve .
For tree view:
python3 ~/.claude/plugins/agent-swarm/ctx/resolver.py tree .
Context File Format
# Context: [Scope Name]
@inherit: true # Default, inherit from parent
@override: conventions # Override this section completely
@priority: high # Mark as high priority
## Purpose
What this scope is for.
## Conventions
Coding standards for this scope.
## Patterns
Common patterns used here.
## Pitfalls
Known issues to avoid.
Creating Context
To add context at current scope:
- Create
.context/CONTEXT.mdin the directory - Add relevant sections
- Use
@overridefor sections that shouldn't merge with parent
Memory vs Context
- CONTEXT.md - Static, intentionally written knowledge
- MEMORY.md - Distilled learnings from sessions (see
/distill)