System file guardrails

From rianvdm/product-ai-public · View interactive version

System file guardrails is an AI agent skill from the GitHub repository rianvdm/product-ai-public. Safety checks for editing system files — commands in .opencode/command/, skills in .opencode/skills/, agents in .opencode/agent/, or AGENTS.md itself. Load when creating or modifying any of these files.

How to use this skill

Skill file

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.

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:

--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:

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? |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.