---
name: agent-instructions-setup
description: Initialize or reorganize agent instruction files (AGENTS.md, CLAUDE.md, GEMINI.md and similar) using AGENTS.md as the canonical file with @AGENTS.md or relative symlinks. Use for /init, creating project instructions, merging an existing CLAUDE.md into AGENTS.md, normalizing instruction links, or deciding whether a rule belongs in global or project-local instructions.
---

# Agent Instructions Setup

Shared global rules live in `~/.codex/AGENTS.md`; other agents reference or
link to it. Project-specific rules live in the project's `AGENTS.md`.

## Initialize (including `/init`)

1. Use `AGENTS.md` as the canonical file.
2. Create `CLAUDE.md` in the same directory (and in any subdirectory that has
   its own `AGENTS.md`):
   - Cross-platform / Windows teams (recommended): create a plain `CLAUDE.md`
     containing `@AGENTS.md`.
   - Unix / WSL2-only repos using symlinks: create a relative symlink
     `CLAUDE.md -> AGENTS.md` (`ln -s AGENTS.md CLAUDE.md`).

## Existing files

- `CLAUDE.md` is a plain file whose only content is `AGENTS.md` (broken symlink
  checkout on Windows): treat it as a broken link and replace with `@AGENTS.md`.
- Only `CLAUDE.md` exists: preserve its content in `AGENTS.md`, then replace
  `CLAUDE.md` with `@AGENTS.md` or the symlink.
- Both exist: compare and reconcile without losing content or changing
  instruction scope. Ask the user about unresolved conflicts.
- Existing links: resolve their targets before normalizing and preserve
  content. Avoid circular links.
- Routine edits: preserve valid links/imports and edit `AGENTS.md`.

## Verify

- Confirm `AGENTS.md` holds the canonical rules and `CLAUDE.md` points to or
  imports it cleanly.
- Confirm the instructions load in the intended agents.

## Scope

- Apply this convention only when initializing or explicitly reorganizing
  instructions.
- Respect explicit repository requirements.
- Keep project-specific guidance project-local; keep only cross-project rules
  in the global file.
