System File Edit Guardrails
Follow these checks when editing system files: commands (.opencode/command/), skills (.opencode/skills/), agents (.opencode/agent/), or AGENTS.md itself.
Where the Real File Lives
There is exactly one copy of each skill on disk. Several paths resolve to it through two layers of symlinks, so a path that looks like a separate file usually isn't.
- Layer 1 — Claude Code → OpenCode:
.claude/skillsand.claude/commandsare folder symlinks into.opencode/. So.claude/skills/<name>/SKILL.mdalways resolves to.opencode/skills/<name>/SKILL.md. For skills and commands there is never a separate Claude Code copy..claude/agentsand.codex/agentsare the exceptions — real directories generated bysync-opencode-agents.py(see below). - Two different
.agents/skills/directories exist. Repo-relative.agents/skills/is this repo's generated Codex view (below). Home-relative~/.agents/skills/is the user-level install of the Cloudflare platform skills, which symlinks on into~/git/cf-skills/skills/. Always check the leading~/. - Layer 1 — Codex → OpenCode:
.agents/skills/is a generated Codex-only view. Its canonical skill entries are folder symlinks to.opencode/skills/<name>. Command adapters use generated regularSKILL.mdpointer files that direct Codex to the canonical.opencode/command/<name>.md; Codex discovers symlinked skill folders but not a symlink used as theSKILL.mdfile itself. The command and skill files remain the only workflow sources; Claude Code and OpenCode never consume the Codex adapters. Run./scripts/sync-codex-resources.shafter adding, renaming, or deleting a command or skill. The nativecodexskill is the only command without an adapter. - Layer 2 — OpenCode → source-of-truth repo: most entries inside
.opencode/skills/are themselves folder symlinks into a source-of-truth clone — typically~/Documents/gitlab/data-skills/.opencode/skills/<name>(data team). Those repos are regular git clones, not symlinks — they are the targets, not the consumers. Edit there, then commit and push from that repo. - Synced copies (not symlinks):
scripts/sync-data-skills.shtracks a few data-skills commands and agents as real local files, listed in itsCOPY_FILES(for exampleask-data-team.md,custesc.md, and theresearchand custesc agents). A copy listed inSKIP_COPY_FILESkeeps its local settings and is never overwritten; any other copy is overwritten on the next sync. When you edit one, either push the change upstream or add it toSKIP_COPY_FILESwith a reason. Each copy has a row inscripts/data-skills-baseline.tsvrecording the upstream commit it was last reviewed against;/merge-data-skillsreviews later upstream changes and moves that row. A new copy needs both aCOPY_FILESentry and a baseline row (validate-agents.shchecks this). - Worked example —
data-clickhouse-queries: ~/git/product-ai/.claude/skills/data-clickhouse-queries/SKILL.md(Claude Code path)- → resolves through the
.claude/skillssymlink to.opencode/skills/data-clickhouse-queries/SKILL.md - → resolves through the
.opencode/skills/data-clickhouse-queriessymlink to~/Documents/gitlab/data-skills/.opencode/skills/data-clickhouse-queries/SKILL.md← real file, only place to edit
Common failure mode: running ls on a file at the end of a symlink chain shows -rw-r--r-- (the target's permissions), which looks like a real file. It isn't — the path you reached it through is still going through symlinks. Before claiming a path is a separate file needing its own edit, run readlink -f <path>, or ls -la every parent component up to the repo root. All three paths above resolve to one inode.
Regenerating `.claude/agents/` and `.codex/agents/`
Agent definitions need per-harness formats (Claude Code Markdown, Codex TOML, and OpenCode Markdown with different frontmatter), so this is the one place the one-copy-on-disk rule does not apply. .opencode/agent/ is the source of truth; regenerate with:
./scripts/sync-opencode-agents.py # create missing only (safe default)
./scripts/sync-opencode-agents.py --all # also refresh existing
./scripts/sync-opencode-agents.py --dry-run # preview
./scripts/sync-opencode-agents.py --check # fail on missing or stale output
Three translation rules matter:
model:is pinned to the full ID"claude-opus-5-5[1m]"— the 1M-context Opus 5.5 variant, quoted because the brackets are YAML flow indicators. Not theopusalias, which floats to whatever the current default Opus is. These agents read large source sets (job traces, whole wiki pages, multi-repo searches), so the bigger window earns its cost; drop the[1m]suffix in the script'sMODELconstant for the standard-context variant.- OpenCode's
tools: {write: false, edit: false}becomesdisallowedTools: Write, Edit, NotebookEditwithtoolsleft unset. Claude Code inherits every tool whentoolsis omitted and subtractsdisallowedToolsfrom it — so this keeps read-only semantics without stripping MCP access. An explicittools:allowlist would silently remove everymcp__*tool. Verify with the Task tool's agent list: it should read "All tools except Write, Edit, NotebookEdit". - Codex receives
name,description, and the Markdown body asdeveloper_instructions. The generator deliberately omitsmodelandmodel_reasoning_effort, so machine-level[agents]defaults remain authoritative.
--dry-run reports only presence (skip (exists)), never content. Use the content-aware check before committing:
./scripts/sync-opencode-agents.py --check
Claude Code hot-reloads .claude/agents/. Start a new Codex session after adding or renaming a custom agent so its role catalog refreshes.
Before Editing
| Check | What to verify |
|-------|---------------|
| Inbound references | Search for the file's name across .opencode/command/, .opencode/skills/, .opencode/agent/, and AGENTS.md. Note files whose assumptions could break if this file changes. |
| Outbound references | What skills, agents, or commands does this file reference? Verify each exists on disk. |
If broken outbound references are found, warn before proceeding (the edit might be fixing them).
After Editing a Command
| Check | What to verify |
|-------|---------------|
| Frontmatter | description present |
| $ARGUMENTS | Parsed and handled (if command accepts arguments) |
| Skill loading | Lazy — no loading during research phases |
| Token efficiency | Compact tables over prose. Nothing duplicated from AGENTS.md |
| MCP tool references | Correct tool names, fallback behavior if tools are unavailable |
After Editing a Skill or Agent
| Check | What to verify |
|-------|---------------|
| Frontmatter | name, description present. Agents: mode, tools also present |
| Description accuracy | Frontmatter description matches what the file actually does |
| Stale references | No references to commands, tools, files, or skills that don't exist |
| Agent quality checklist | Present and covers the agent's actual scope |
Writing the Content
The checks above cover mechanics. For the writing — what earns its place in a file that loads into every session — two references, which agree more than they appear to:
superpowers:writing-skills— TDD for documentation. Baseline-test first, and its Match the Form to the Failure table: prohibitions and rationalization tables work for discipline failures (agent knows the rule, skips it under pressure) and measurably backfire on shaping failures (output has the wrong form), where a positive recipe wins.- Matt Pocock's
writing-for-agents— the pruning lens. Read the real files, not the overview page:gh api repos/mattpocock/skills/contents/skills/productivity/writing-for-agents/SKILL.md --jq .content | base64 -d, plus its siblingSKILL-MECHANICS.mdfor frontmatter and the model- vs user-invoked choice. Five levers: context pointers (the pointer's wording, not its target, decides reliability — one trigger per branch), information hierarchy (in-file step → in-file reference → disclosed reference; inline what every branch needs, push behind a pointer what only some branches reach), completion criteria (checkable and exhaustive — "every rule applied" drives legwork where "produce a list" does not), leading words (a pretrained concept repeated as a token, never as a sentence), and pruning (the no-op test: delete the line, did behaviour change? If not, delete the whole sentence, not some words).
Where they look opposed they aren't: Pocock calls negation a failure mode — "Don't think of an elephant, and the elephant is all there is" — which is the same finding as superpowers' shaping-vs-discipline split, reached from the other side. Default to the positive recipe unless the failure is genuinely one of discipline.
Post-Session Coherence
When 2+ system files are modified in a session, offer a coherence check before wrapping up:
"You modified N system files this session — running a quick coherence check."
| Check | What to verify |
|-------|---------------|
| Cross-references | Do modified files' references to other files still resolve? |
| Scope alignment | If a convention spans multiple files, do they use consistent language? |
| Displaced content | Were any existing sections accidentally removed or overwritten? |