Force the agents-md skill before any AGENTS.md write - #2
Open
j0ntz wants to merge 1 commit into
Open
Conversation
An AGENTS.md is loaded into every session for its repo, so a careless one taxes every future task there and fails silently. Pair a skill with a gate: - .cursor/skills/agents-md/SKILL.md holds the guidance (size budget, the what/why/how to include, the exclude list, progressive disclosure, pointers over pasted code), cached from philschmid.de/writing-good-agents so applying it never needs a fetch. - require-agents-md-skill.sh (PreToolUse) blocks writes to any AGENTS.md, in any repo, until the skill is loaded that session. Covers Write/Edit by file_path and Bash by redirect/tee/heredoc; Bash reads still pass. - mark-agents-md-skill-read.sh (PostToolUse) clears the gate on a Skill call, a Read of the SKILL.md, or a Bash reference to it. Session-keyed rather than task-keyed so it also covers interactive edits outside orchestrated runs.
j0ntz
marked this pull request as ready for review
July 31, 2026 20:43
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
An
AGENTS.mdis loaded into every session for its repo, so a careless one taxes every future task there, and it fails silently rather than loudly. The usual failure is the confident first draft: a directory listing, pasted code snippets, and style rules the linter already enforces. Measured, that file performs worse than having no file at all.This adds a skill/gate pair so the guidance is unavoidable at the moment it matters.
.cursor/skills/agents-md/SKILL.md— the guidance: the size budget, the WHAT/WHY/HOW to include, the exclude list (directory listings, style rules, task-specific instructions, auto-generated or doc-duplicating content), progressive disclosure, pointers over pasted code, and a pre-save checklist. Distilled from philschmid.de/writing-good-agents and cached in the skill, so applying it never depends on a fetch.agent-watcher/hooks/require-agents-md-skill.sh(PreToolUse) — blocks writes to anyAGENTS.md, in any repo, until the skill is loaded that session. Covers both authoring vectors:Write/Editbyfile_path, andBashby redirect/tee/heredoc. Bash reads (cat,grep,wc) still pass.agent-watcher/hooks/mark-agents-md-skill-read.sh(PostToolUse) — clears the gate on aSkillcall, aReadof the SKILL.md, or a Bash reference to it.claude-settings/hooks.json— registers both, plus the rubric-drift lock (the skill is excluded from rubric coverage: it is repo-authoring tooling, not part of the one-shot delegation chain).The marker is session-keyed rather than task-keyed, so this also covers interactive edits outside orchestrated runs. The gate is not one-bounce: it blocks until the skill is loaded, and the remedy is a single call.
Testing
Write/EditonAGENTS.md(nested paths and case variants) blocked;README.mdpasses; Bash>,>>,tee,tee -a, and heredoc into anAGENTS.mdblocked; Bashcat/grep/wcreads pass; marker set by each of theSkill,Read, andBashpaths and by none of the unrelated ones.Writeto anAGENTS.mdwas blocked by the hook with its guidance message; aSkillcall toagents-mdset the marker; the same write then succeeded.AGENTS.mdadded in Add swaps.xyz swap provider edge-exchange-plugins#480 was rewritten against this skill, 117 → 68 lines (dropped the directory listing, the pasted factory snippet, and the style rules).Asana: https://app.asana.com/0/1215088146871429/1217036054017879