agent-context-manager

Automatically detects and loads AGENTS.md files to provide agent-specific instructions

View on GitHub
Author Jeremy Longshore
Namespace @jeremylongshore/claude-code-plugins-plus
Category productivity
Version 1.0.0
Stars 1,193
Downloads 24
self.md verified
Table 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.

Version Category Agent Skills Anthropic Spec


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

  1. Create AGENTS.md in your project root:
cd /path/to/your/project
nano AGENTS.md
  1. 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
  1. 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:

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:

  1. Finds all AGENTS.md files in your project
  2. Reads their content
  3. Merges into CLAUDE.md under “## Agent-Specific Instructions” section
  4. 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?

  1. Layer 1 = Ideal (fully automatic)
  2. Layer 2 = Backup (semi-automatic reminder)
  3. 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)
Tags: productivity agentscontextautomation