Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 38 additions & 22 deletions .agents/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,72 @@
# `.agents/`

Agent-agnostic configuration following the [Agent Skills](https://agentskills.io)
open standard and [AGENTS.md](https://agents.md) conventions.
The one canonical agent folder, following the
[Agent Skills](https://agentskills.io) open standard and
[AGENTS.md](https://agents.md) conventions.

Every piece of agent configuration is one of three things:

| Category | Strategy |
| Tier | Strategy |
|---|---|
| **Portable** — same format everywhere | Store once here, symlink into agent directories |
| **Generated** — same data, different format | Canonical source here, sync script renders each adapter |
| **Agent-specific** — no cross-agent equivalent | Leave it in the agent's own directory |
| **Canonical** — the single source of truth | Lives here: `skills/`, `mcp/servers.json`, `scripts/` |
| **Seed** — a harness reads it straight from the clone, before any script can run | Committed in the harness's own location, kept minimal: hook and environment registrations, one managed key per settings file |
| **Generated** — everything else a harness wants | Rendered by `scripts/sync.py`, gitignored, recreated per checkout for the harnesses detected on that machine |

Portable things get symlinks, generated things get a sync script, agent-specific
things stay put.
Instructions and skills need almost no adapters: `AGENTS.md` and
`.agents/skills/` are read natively by Codex, Cursor, Copilot's coding agent,
OpenCode, Amp, Factory, Windsurf, Hermes, Trae, Augment, Goose, Zed, Crush,
Kilo, Antigravity, dsh, and gsd, among others — only Claude Code and CodeBuddy
get generated skill symlinks. What `sync.py` mostly renders is MCP configs for
tools with a project-level MCP surface; `sync.py list` shows the full table.

## Layout

- `skills/` — Shared skills. Each is a directory with `SKILL.md`.
- `mcp/servers.json` — Canonical MCP server configuration.
- `scripts/` — Portable environment setup, synchronization, and validation.
- `mcp/servers.json` — Canonical MCP server configuration (Claude `mcpServers`
dialect, plus an optional `tools` read-only allowlist per server).
- `scripts/` — `bootstrap.sh` (environment setup entry point), `sync.py`
(adapter generator), `check-skills.py` (vendored-skill lock).
- `setup` — Entry shim for harnesses that execute `.agents/setup` (Amp orbs).

## Adding a skill

1. Create `.agents/skills/<name>/SKILL.md` with `name` and `description`
frontmatter, where `name` matches the directory.
2. Run `.agents/scripts/link-skills.sh` and `.agents/scripts/check-skills.py --update`.
3. Commit the skill directory, the generated symlinks, and `skills-lock.json`.
2. Run `.agents/scripts/sync.py` and `.agents/scripts/check-skills.py --update`.
3. Commit the skill directory and `skills-lock.json`. Skill symlinks are
generated and gitignored — do not commit them.

## Installing a third-party skill

```bash
npx skills add <repo>@<skill> -y
```

It installs into `.agents/skills/` and maintains the same `skills-lock.json`.

## Adding an MCP server

1. Edit `.agents/mcp/servers.json`.
2. Run `.agents/scripts/sync-mcp.sh`.
3. Commit the canonical file and all generated adapters.
2. Run `.agents/scripts/sync.py`.
3. Commit the canonical file plus the two committed seeds it updates
(`.claude/settings.json`, `.gemini/settings.json`). Every other rendered
adapter is gitignored.

An optional `tools` array on a server is a read-only allowlist. It renders as
`enabled_tools` for Codex and `includeTools` for Gemini; Claude Code and Cursor
have no equivalent and receive the server's whole tool surface.
`enabled_tools` for Codex and `includeTools` for Gemini and Qwen; the other
harnesses have no equivalent and receive the server's whole tool surface.

## Rules

- Edit skills in `.agents/skills/`, never through `.claude/skills/` or
`.cursor/skills/`.
- Edit MCP definitions in `.agents/mcp/servers.json`, never in `.mcp.json`,
`.cursor/mcp.json`, `.codex/config.toml`, or `.gemini/settings.json`.
- `.claude/settings.json` and `.gemini/settings.json` are hand-owned except for
their `enabledMcpjsonServers` and `mcpServers` keys, which the sync rewrites.
- Edit skills in `.agents/skills/`, never through a harness's skills directory —
those are symlinks or native readers of this one.
- Edit MCP definitions in `.agents/mcp/servers.json`, never in a rendered
adapter.
- To support a new harness, add one entry to the `HARNESSES` table in
`scripts/sync.py` (detection, skills dir if it doesn't read `.agents/skills/`
natively, MCP renderer if it has a project-level MCP file) and mirror any new
output path in `.gitignore`'s generated-adapters block. CI fails if the two
fall out of step.
- Agent-specific configuration stays put. `.cursor/rules/*.mdc` and
`.github/instructions/*.instructions.md` use glob scoping and conditional
loading with no equivalent elsewhere — do not convert them into skills.
Expand Down
57 changes: 36 additions & 21 deletions .agents/README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,66 @@
# Agent configuration

This directory is the canonical home for portable agent assets. Shared skills
are symlinked into tool-native discovery paths; MCP definitions are rendered
into each tool's configuration format.
follow the Agent Skills standard and are read from `.agents/skills/` natively
by most harnesses (symlinked into the few that still want their own
directory); MCP definitions are rendered into each tool's configuration
format. Rendered adapters are gitignored and recreated per checkout.

## Commands

```bash
# Install development tooling and refresh agent configuration
.agents/scripts/bootstrap.sh

# Create or refresh shared-skill symlinks
.agents/scripts/link-skills.sh
# Render adapters for the harnesses detected on this machine
.agents/scripts/sync.py

# Regenerate the Claude, Cursor, Codex, and Gemini MCP adapters
.agents/scripts/sync-mcp.sh
# Render adapters for every known harness / a specific one
.agents/scripts/sync.py --all
.agents/scripts/sync.py opencode

# Fail if an MCP adapter is missing or stale
.agents/scripts/sync-mcp.sh check
# Show the harness table: detection state and what each gets
.agents/scripts/sync.py list

# Fail if a managed key in a committed seed file is stale
.agents/scripts/sync.py check

# Explicitly install this repo's managed MCP block in the user Codex config
.agents/scripts/sync-mcp.sh install-codex
.agents/scripts/sync.py install-codex

# Verify skills-lock.json against the skills on disk (--update to re-lock)
.agents/scripts/check-skills.py
```

## Cloud environments
## Environments

Every environment runs the same script. Nothing is environment-specific except
the hook that calls it:
Every environment runs the same `bootstrap.sh`. Nothing is
environment-specific except the hook that calls it:

| Environment | Entry point |
|---|---|
| Local | `.agents/scripts/bootstrap.sh`, once per checkout |
| Claude Code (web) | `SessionStart` hook → `.claude/hooks/session-start.sh` |
| Codex cloud | `.codex/environments/environment.toml` `[setup] script` |
| GitHub Codespaces / devcontainers | `.devcontainer/devcontainer.json` `postCreateCommand` |
| Claude Code (web/cloud) | `SessionStart` hook → `.claude/hooks/session-start.sh` |
| GitHub Codespaces / devcontainers / Ona | `.devcontainer/devcontainer.json` `postCreateCommand` |
| GitHub Copilot coding agent | `.github/workflows/copilot-setup-steps.yml` (devcontainers are not honored there) |
| Cursor cloud agents | `.cursor/environment.json` `install` |
| Amp orbs | `.agents/setup` |
| Codex cloud | No in-repo hook — put `.agents/scripts/bootstrap.sh` in the environment's Setup script field (chatgpt.com/codex/settings/environments) |
| Jules / Devin / Factory | No in-repo hook — same one-liner in their UI setup/snapshot configuration |
| CI | `.github/workflows/agent-config.yml` |

To add another environment, call `bash .agents/scripts/bootstrap.sh` from its
native setup hook. Do not fork the setup logic.
native setup hook. Do not fork the setup logic. Bootstrap must stay
idempotent, non-interactive, fast when there is nothing to do, and free of
secrets at setup time (Codex cloud strips them before the agent phase).

## Generated files

`.mcp.json`, `.cursor/mcp.json`, `.codex/config.toml`, and the `mcpServers` and
`enabledMcpjsonServers` keys of `.gemini/settings.json` and
`.claude/settings.json` are generated from `.agents/mcp/servers.json`. The
`Validate agent configuration` workflow enforces synchronization on pull
requests and pushes to `main`; the bootstrap installs the local hook.
`sync.py` renders adapters from `.agents/mcp/servers.json` and links
`.agents/skills/` for harnesses that don't read it natively — by default only
for harnesses it detects on the machine (CLI on PATH, config directory, or
environment variable; CI renders all). All of it is gitignored; the
`Validate agent configuration` workflow fails if a rendered file ever shows up
untracked. The two committed exceptions, `.claude/settings.json` and
`.gemini/settings.json`, are hand-owned apart from one managed key each
(`enabledMcpjsonServers`, `mcpServers`), which `sync.py check` keeps honest.
11 changes: 6 additions & 5 deletions .agents/scripts/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
# Agent-agnostic environment setup for a fresh checkout.
#
# Safe to re-run; every step is idempotent. Works locally and in remote agent
# containers (Claude Code on the web, Codex cloud, Codespaces, CI).
# Safe to re-run; every step is idempotent and non-interactive. Every
# environment calls this same script through its native hook — see the
# environments table in .agents/README.md.
set -euo pipefail

REPO_ROOT="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
Expand All @@ -19,10 +20,10 @@ if ! command -v pre-commit >/dev/null 2>&1; then
fi
fi

.agents/scripts/link-skills.sh
.agents/scripts/sync-mcp.sh
.agents/scripts/sync.py "$@"
.agents/scripts/check-skills.py
pre-commit install

# Project setup goes here (dependency install, codegen, migrations). Keep it
# idempotent so every harness can call this script on every session start.
# idempotent and fast when there is nothing to do, so every harness can call
# this script on every session start.
42 changes: 0 additions & 42 deletions .agents/scripts/link-skills.sh

This file was deleted.

Loading