From de16995f350d78e4e8cefe0896ec2411d6a2eefb Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Mon, 23 Nov 2026 19:14:00 +0000 Subject: [PATCH 1/4] ci(pre-commit): refuse CLAUDE.md files by hook Claude Code reads CLAUDE.md in place of AGENTS.md, so a stray CLAUDE.md, CLAUDE.local.md or .claude/CLAUDE.md at any depth leaves an agent without this repository's guidance, and nothing reports it. A language: fail hook refuses such a file at commit time. Refs: #244 Assisted-by: Claude Code --- .pre-commit-config.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25c30c4..12e411f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -126,6 +126,16 @@ repos: require_serial: true fail_fast: true + # apm compile (target claude), a tool's project init or a skill can create a CLAUDE.md, and + # the failure is silent: the agent gets no guidance and no error. + - id: refuse-claude-md + name: Refuse CLAUDE.md files + description: refuse CLAUDE.md, CLAUDE.local.md and .claude/CLAUDE.md at any depth + entry: a CLAUDE.md file makes Claude Code ignore every AGENTS.md; delete it + language: fail + files: (^|/)(\.claude/)?CLAUDE(\.local)?\.md$ + stages: ['pre-commit'] + - repo: meta hooks: - id: check-hooks-apply From b23288715357404a5da7a67779d6b5717403de47 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Mon, 23 Nov 2026 19:14:07 +0000 Subject: [PATCH 2/4] ci(images): bump the ci image for the hook change .pre-commit-config.yaml is an input of the ci image, so the new hook needs a new image version (0.2.35 -> 0.2.36). Refs: #244 Assisted-by: Claude Code --- .gitea/workflows/image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/image.yml b/.gitea/workflows/image.yml index a943a50..32f1b4d 100644 --- a/.gitea/workflows/image.yml +++ b/.gitea/workflows/image.yml @@ -87,7 +87,7 @@ jobs: dockerfile: Dockerfile job_image: ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db - name: ci - version: 0.2.35 + version: 0.2.36 subpath: "" dockerfile: images/ci/Dockerfile job_image: ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db From 35e780cf7990a1b3f7833fe57ac9852878a955d2 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Mon, 23 Nov 2026 19:16:17 +0000 Subject: [PATCH 3/4] ci(check_tarball): refuse AGENTS.md at any depth An AGENTS.md under roles/ holds contributor rules; shipped in the Collection, a consumer's agent reading an installed role would load them. galaxy.yml build_ignore lists the current ones, and the archive check now refuses any AGENTS.md, compared case-insensitively, as the allow list behind that deny list. A root AGENTS.md was already refused by ALLOWED_TOP. Refs: #244 Assisted-by: Claude Code --- scripts/check_tarball.py | 2 ++ tests/scripts/test_check_tarball.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/scripts/check_tarball.py b/scripts/check_tarball.py index e672fb8..a5a7686 100644 --- a/scripts/check_tarball.py +++ b/scripts/check_tarball.py @@ -89,6 +89,8 @@ FORBIDDEN = [ "*.env.*", "*/.env*", ".env*", + # Contributor rules: a consumer's agent reading an installed role would load them. + "*/agents.md", ] # Names Windows treats as devices, with or without an extension (and with trailing spaces). WINDOWS_RESERVED = { diff --git a/tests/scripts/test_check_tarball.py b/tests/scripts/test_check_tarball.py index 77ddf3d..1486a05 100644 --- a/tests/scripts/test_check_tarball.py +++ b/tests/scripts/test_check_tarball.py @@ -70,6 +70,22 @@ class TarballTest(unittest.TestCase): self.assertEqual(len(found), 1, name) self.assertIn("forbidden pattern", found[0], name) + def test_agents_md_is_refused_at_any_depth(self): + for name in ( + "roles/AGENTS.md", + "roles/x/AGENTS.md", + "roles/x/templates/Agents.md", + ): + found = check_tarball.problems([name]) + self.assertEqual(len(found), 1, name) + self.assertIn("forbidden pattern", found[0], name) + self.assertEqual( + check_tarball.problems( + ["roles/x/README.md", "roles/x/files/agents_notes.md"] + ), + [], + ) + def test_ambiguous_names_are_rejected(self): cases = { "roles/a/x ": "ends in a space or a dot", From 161e5bff63269145704f24c1ddc347e7cbd6fd57 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Mon, 23 Nov 2026 19:48:12 +0000 Subject: [PATCH 4/4] ci(images): bump the ci image past main's 0.2.36 main raised ci to 0.2.36 for its own .pre-commit-config.yaml change, so the hook change here needs 0.2.37. Refs: #244 Assisted-by: Claude Code --- .gitea/workflows/image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/image.yml b/.gitea/workflows/image.yml index 32f1b4d..33a4109 100644 --- a/.gitea/workflows/image.yml +++ b/.gitea/workflows/image.yml @@ -87,7 +87,7 @@ jobs: dockerfile: Dockerfile job_image: ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db - name: ci - version: 0.2.36 + version: 0.2.37 subpath: "" dockerfile: images/ci/Dockerfile job_image: ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db