ctx

c-daly's avatarfrom c-daly

View and manage hierarchical context for the current directory

0stars🔀0forks📁View on GitHub🕐Updated Jan 11, 2026

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.
namectx
descriptionView and manage hierarchical context for the current directory
user_invocabletrue

/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:

  1. Feature/Component level - .context/CONTEXT.md in current or parent dirs
  2. Repo level - .claude/CONTEXT.md at repository root
  3. Project level - Context above the repo
  4. User level - ~/.claude/CONTEXT.md for 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:

  1. Create .context/CONTEXT.md in the directory
  2. Add relevant sections
  3. Use @override for sections that shouldn't merge with parent

Memory vs Context

  • CONTEXT.md - Static, intentionally written knowledge
  • MEMORY.md - Distilled learnings from sessions (see /distill)
ctx – AI Agent Skills | Claude Skills