Skip to content
Back to skills

380 Sync Agent Context 88ea898c

ASecurity

**Command**: `/sync-agent-context` **Purpose**: Permanently merge all `AGENTS.md` files in the project into `CLAUDE.md` under a dedicated section, ensuring agent-specific instructions are always loaded alongside project context. ---

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
developmentjavascripttypescriptjavabashgit

Works with

  • claude code

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 380-sync-agent-context_88ea898c --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 380 Sync Agent Context 88ea898c?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 380 Sync Agent Context 88ea898c
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-380-sync-agent-context-88ea898c/badge)](https://www.skillsdirectory.com/skills/tools-only-380-sync-agent-context-88ea898c)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Sync Agent Context - Slash Command

**Command**: `/sync-agent-context`

**Purpose**: Permanently merge all `AGENTS.md` files in the project into `CLAUDE.md` under a dedicated section, ensuring agent-specific instructions are always loaded alongside project context.

---

## What This Command Does

1. **Finds all AGENTS.md files** in the current project directory (searches recursively)
2. **Reads each AGENTS.md file** and extracts its content
3. **Updates CLAUDE.md** by adding or updating the "## Agent-Specific Instructions" section
4. **Maintains both files**: Keeps original AGENTS.md files as the source of truth
5. **Creates backup**: Saves a backup of CLAUDE.md before making changes

---

## Execution Steps

### Step 1: Find All AGENTS.md Files

Search the current project for all files named `AGENTS.md`:

```bash
find . -name "AGENTS.md" -type f
```

**Expected output**:
```
./AGENTS.md
./subproject/AGENTS.md
```

### Step 2: Read Each AGENTS.md File

For each found file, read its full content using the Read tool:

```markdown
File: ./AGENTS.md
Content: [full content of AGENTS.md]

File: ./subproject/AGENTS.md
Content: [full content of subproject AGENTS.md]
```

### Step 3: Check if CLAUDE.md Exists

```bash
if [ -f "./CLAUDE.md" ]; then
    echo "CLAUDE.md found - will update"
else
    echo "CLAUDE.md not found - will create new file"
fi
```

### Step 4: Create Backup of CLAUDE.md

```bash
cp CLAUDE.md CLAUDE.md.backup.$(date +%Y%m%d-%H%M%S)
```

**Example**: `CLAUDE.md.backup.20251023-143022`

### Step 5: Merge AGENTS.md into CLAUDE.md

Add or update the following section in CLAUDE.md:

```markdown
---

## Agent-Specific Instructions

<!-- AUTO-SYNCED from AGENTS.md files - Last updated: 2025-10-23 14:30:22 -->
<!-- Source files: ./AGENTS.md, ./subproject/AGENTS.md -->

### Root Directory Agent Rules (./AGENTS.md)

[Content from ./AGENTS.md]

### Subproject Agent Rules (./subproject/AGENTS.md)

[Content from ./subproject/AGENTS.md]

---
```

### Step 6: Verify and Report

```markdown
βœ… Agent Context Sync Complete!

πŸ“‹ Summary:
- Found 2 AGENTS.md files
- Created backup: CLAUDE.md.backup.20251023-143022
- Updated CLAUDE.md with agent-specific instructions

πŸ“‚ Synced files:
1. ./AGENTS.md β†’ CLAUDE.md (Section: Root Directory Agent Rules)
2. ./subproject/AGENTS.md β†’ CLAUDE.md (Section: Subproject Agent Rules)

⚠️ Note: Original AGENTS.md files remain unchanged (source of truth)

πŸ’‘ Next time you start Claude Code, both CLAUDE.md and AGENTS.md will be loaded automatically.
```

---

## When to Use This Command

**Use `/sync-agent-context` when:**

1. **Initial setup**: First time using agent-specific instructions
2. **AGENTS.md not auto-loading**: If the proactive skill isn't triggering
3. **Permanent merge desired**: Want agent rules always in CLAUDE.md
4. **Multiple AGENTS.md files**: Have agent rules across different directories
5. **Manual control preferred**: Want explicit control over when rules are merged

**Don't use this command if:**

- Automatic loading is working fine (skill handles it)
- You want AGENTS.md and CLAUDE.md to remain separate
- You frequently update AGENTS.md (would require re-running sync)

---

## Merge Strategy

### If "Agent-Specific Instructions" section exists in CLAUDE.md:

**Replace** the existing section with updated content from all AGENTS.md files.

```markdown
## Agent-Specific Instructions
<!-- OLD CONTENT - WILL BE REPLACED -->

↓↓↓ BECOMES ↓↓↓

## Agent-Specific Instructions
<!-- NEW CONTENT FROM AGENTS.MD FILES -->
```

### If "Agent-Specific Instructions" section doesn't exist:

**Append** new section to the end of CLAUDE.md.

```markdown
[Existing CLAUDE.md content]

---

## Agent-Specific Instructions
<!-- NEW SECTION ADDED -->
[Content from AGENTS.md files]
```

---

## Conflict Resolution

**If both CLAUDE.md and AGENTS.md have conflicting rules:**

The sync command will:
1. Keep original CLAUDE.md content intact
2. Add AGENTS.md content in dedicated section
3. Document in the header: "In case of conflicts, Agent-Specific Instructions take precedence"

**Example merged output**:

```markdown
# CLAUDE.md

## General Project Instructions
- Use TypeScript for all code (from original CLAUDE.md)

---

## Agent-Specific Instructions
<!-- In case of conflicts, these rules take precedence for agent workflows -->

- Use JavaScript for agent-generated code (from AGENTS.md)
```

**Result**: Agent workflows use JavaScript; manual work uses TypeScript

---

## Automated Sync (Future Enhancement)

**Not currently implemented**, but could be added:

```json
// plugin.json future enhancement
{
  "hooks": {
    "onFileChange": {
      "pattern": "**/AGENTS.md",
      "action": "run /sync-agent-context automatically"
    }
  }
}
```

This would auto-sync whenever AGENTS.md is modified.

---

## Examples

### Example 1: Single AGENTS.md File

**Before**:
```
project/
β”œβ”€β”€ CLAUDE.md (200 lines)
└── AGENTS.md (50 lines)
```

**Run**: `/sync-agent-context`

**After**:
```
project/
β”œβ”€β”€ CLAUDE.md (250 lines - merged)
β”œβ”€β”€ CLAUDE.md.backup.20251023-143022 (original)
└── AGENTS.md (50 lines - unchanged)
```

### Example 2: Multiple AGENTS.md Files

**Before**:
```
project/
β”œβ”€β”€ CLAUDE.md
β”œβ”€β”€ AGENTS.md
└── packages/
    └── plugin-a/
        └── AGENTS.md
```

**Run**: `/sync-agent-context`

**After**:
```
CLAUDE.md now contains:
## Agent-Specific Instructions

### Root Directory Agent Rules
[Content from ./AGENTS.md]

### Package Plugin-A Agent Rules
[Content from ./packages/plugin-a/AGENTS.md]
```

---

## Best Practices

1. **Run sync after updating AGENTS.md**: Keep CLAUDE.md synchronized
2. **Review backup before sync**: Check `CLAUDE.md.backup.*` files if needed
3. **Maintain AGENTS.md as source**: Edit AGENTS.md, then re-run sync
4. **Use version control**: Commit both files to git after sync
5. **Document sync frequency**: Add comment in AGENTS.md: "Sync to CLAUDE.md: monthly"

---

## Troubleshooting

**Problem**: Sync command not found

**Solution**: Ensure plugin is installed:
```bash
/plugin install agent-context-manager@claude-code-plugins-plus
```

**Problem**: CLAUDE.md section duplicated

**Solution**: Sync command should replace, not duplicate. Check for:
- Multiple "## Agent-Specific Instructions" headers (manual edit error)
- Re-run sync to clean up duplicates

**Problem**: Backup files accumulating

**Solution**: Clean old backups periodically:
```bash
find . -name "CLAUDE.md.backup.*" -mtime +30 -delete
```

---

## Related Features

- **Auto-Loading Skill**: `agent-context-loader` - Automatically loads AGENTS.md
- **Hook Script**: `check-agents-md.sh` - Detects AGENTS.md on directory change
- **Manual Loading**: Say "load agent context" to trigger skill manually

---

**Status**: Manual Command
**Requires User Action**: Yes (type `/sync-agent-context`)
**Permanent**: Yes (persists in CLAUDE.md)

Files in this skill

  • README.md1.1 KB
  • skill.md6.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.