Skip to content

Commit 3fa7114

Browse files
Thomas TupperThomas Tupper
authored andcommitted
ci: enforce AGENTS.md instruction consistency
1 parent 83dff3c commit 3fa7114

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: instruction-consistency
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 2
15+
- name: Check agent instruction consistency
16+
run: ./scripts/check-agent-instructions.sh
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if ! git rev-parse --verify HEAD >/dev/null 2>&1; then
5+
echo "No commits yet; skipping instruction consistency check."
6+
exit 0
7+
fi
8+
9+
changed_files="$(git diff --name-only HEAD~1..HEAD 2>/dev/null || true)"
10+
11+
needs_sync=false
12+
if echo "$changed_files" | grep -Eq '(^|/)AGENTS\.md$'; then
13+
needs_sync=true
14+
fi
15+
if echo "$changed_files" | grep -Eq '(^|/)CLAUDE\.md$|(^|/)CODEX\.md$|(^|/)\.github/copilot-instructions\.md$|(^|/)\.cursor/rules/00-read-agents\.mdc$'; then
16+
needs_sync=true
17+
fi
18+
19+
if [ "$needs_sync" = true ]; then
20+
missing=()
21+
for f in AGENTS.md CLAUDE.md CODEX.md .github/copilot-instructions.md .cursor/rules/00-read-agents.mdc; do
22+
[ -f "$f" ] || missing+=("$f")
23+
done
24+
if [ ${#missing[@]} -gt 0 ]; then
25+
echo "Missing required instruction files: ${missing[*]}"
26+
exit 1
27+
fi
28+
29+
grep -q 'canonical' AGENTS.md || { echo "AGENTS.md should declare canonical guidance"; exit 1; }
30+
grep -q 'AGENTS.md' CLAUDE.md || { echo "CLAUDE.md must point to AGENTS.md"; exit 1; }
31+
grep -q 'AGENTS.md' CODEX.md || { echo "CODEX.md must point to AGENTS.md"; exit 1; }
32+
grep -q 'AGENTS.md' .github/copilot-instructions.md || { echo "Copilot instructions must point to AGENTS.md"; exit 1; }
33+
fi
34+
35+
echo "Agent instruction consistency check passed."

0 commit comments

Comments
 (0)