agent-context-manager
Automatically detects and loads AGENTS.md files to provide agent-specific instructions
View on GitHubTable of content
Automatically detects and loads AGENTS.md files to provide agent-specific instructions
Installation
npx claude-plugins install @jeremylongshore/claude-code-plugins-plus/agent-context-manager
Contents
Folders: commands, skills
Files: LICENSE, README.md
Documentation
Automatically load AGENTS.md files alongside CLAUDE.md for specialized agent-specific instructions.
Problem This Solves
Before: Claude Code only reads CLAUDE.md automatically. If you want agent-specific instructions separate from general project context, you have to manually manage them or pollute CLAUDE.md with agent-only rules.
After: Create AGENTS.md in any directory, and Claude Code will automatically detect and load it alongside CLAUDE.md, enabling specialized agent behaviors without manual intervention.
Quick Start
Installation
/plugin install agent-context-manager@claude-code-plugins-plus
Basic Usage
- Create AGENTS.md in your project root:
cd /path/to/your/project
nano AGENTS.md
- Add agent-specific rules:
# AGENTS.md - Agent-Specific Instructions
## Agent Behavior Rules
When working with Agent Skills in this project:
1. **Always use TypeScript strict mode** for all generated code
2. **Never create files** without explicit user permission
3. **Follow naming convention**: use kebab-case for all file names
4. **Auto-commit after changes**: Create git commits automatically
## Specialized Workflows
### Code Generation
- Use templates from `./templates/` directory
- Run ESLint after generating any .ts/.js files
- Add comprehensive JSDoc comments
- That’s it! Start Claude Code and the plugin will automatically:
- Detect AGENTS.md
- Load the content
- Apply the rules for your session
Features
โก Automatic Loading (Layer 1: Proactive Skill)
The plugin automatically detects and loads AGENTS.md when:
- Starting a new Claude Code session
- Changing directories (via
cdcommand) - Invoking any other agent skill
User Experience:
๐ Loaded agent-specific context from AGENTS.md
Following specialized agent rules for this session:
- Always use TypeScript strict mode
- Never create files without permission
- Follow kebab-case naming convention
No user action required!
๐ Directory Change Detection (Layer 2: Hooks)
When you enter a directory with AGENTS.md, you’ll see:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ AGENTS.md detected in current directory
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โก Agent Context Manager is active
The agent-context-loader skill will automatically load
agent-specific instructions from AGENTS.md
Location: /path/to/project/AGENTS.md
What happens next:
1. Claude will read AGENTS.md automatically
2. Agent-specific rules will be incorporated
3. Instructions will be active for this session
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Manual Synchronization (Layer 3: Slash Command)
Permanently merge AGENTS.md into CLAUDE.md:
/sync-agent-context
What it does:
- Finds all AGENTS.md files in your project
- Reads their content
- Merges into CLAUDE.md under “## Agent-Specific Instructions” section
- Creates backup:
CLAUDE.md.backup.TIMESTAMP
Result:
## Agent-Specific Instructions
### Root Directory Agent Rules (./AGENTS.md)
[Content from ./AGENTS.md]
### Subproject Agent Rules (./packages/app/AGENTS.md)
[Content from ./packages/app/AGENTS.md]
Architecture
Three-Layer Redundancy System
Layer 1: Proactive Skill (agent-context-loader)
โ
Automatically invoked when context needed
โ
Reads AGENTS.md using Read tool
โ
Loads into session context
Layer 2: Directory Change Hook (check-agents-md.sh)
โ
Runs on cd, session start
โ
Prints detection message
โ
Reminds Claude to load AGENTS.md
Layer 3: Manual Sync Command (/sync-agent-context)
โ
User explicitly merges AGENTS.md โ CLAUDE.md
โ
Permanent solution
โ
AGENTS.md always loaded
Why three layers?
- Layer 1 = Ideal (fully automatic)
- Layer 2 = Backup (semi-automatic reminder)
- Layer 3 = Fallback (manual permanent merge)
This ensures AGENTS.md is always loaded, even if one layer fails.
Usage Examples
Example 1: Single Project with Agent Rules
Project Structure:
my-project/
โโโ CLAUDE.md # General project context
โโโ AGENTS.md # Agent-specific rules
โโโ src/
โโโ index.ts
Workflow:
cd my-project
# Plugin automatically detects AGENTS.md
# Claude loads both CLAUDE.md and AGENTS.md
# Agent rules are active for this session
Example 2: Multi-Package Monorepo
Project Structure:
monorepo/
โโโ CLAUDE.md
โโโ AGENTS.md # R
...(truncated)
## Included Skills
This plugin includes 1 skill definition:
### agent-context-loader
> |
<details>
<summary>View skill definition</summary>
# Agent Context Loader
## Overview
This skill provides automated assistance for the described functionality.
## Prerequisites
- Access to project files in {baseDir}/
- Required tools and dependencies installed
- Understanding of skill functionality
- Permissions for file operations
## Instructions
1. Identify skill activation trigger and context
2. Gather required inputs and parameters
3. Execute skill workflow systematically
4. Validate outputs meet requirements
5. Handle errors and edge cases appropriately
6. Provide clear results and next steps
## Output
- Primary deliverables based on skill purpose
- Status indicators and success metrics
- Generated files or configurations
- Reports and summaries as applicable
- Recommendations for follow-up actions
## Error Handling
See `{baseDir}/references/errors.md` for comprehensive error handling.
## Examples
See `{baseDir}/references/examples.md` for detailed examples.
## Resources
- Official documentation for related tools
- Best practices guides
- Example use cases and templates
- Community forums and support channels
</details>
## Source
[View on GitHub](https://github.com/jeremylongshore/claude-code-plugins-plus-skills)