netresearch/agent-rules-skill / skills/agent-rules
agent-rules
FlaggedUse when creating or updating AGENTS.md files, .github/copilot-instructions.md, or other AI agent rule files, onboarding AI agents to a project, standardizing agent documentation, or when anyone mentions AGENTS.md, agent rules, project onboarding, or codebase documentation for AI agents.
scripts/tests/test-scope-index-heading.sh
View on GitHub#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Netresearch DTT GmbH
# Regression test for the scope-index heading contract between
# generate-agents.sh and validate-structure.sh (issue #55).
#
# generate-agents.sh emits the root scope index under the heading
# "## Scoped AGENTS.md (MUST read when working in these directories)"
# while older output used the legacy heading
# "## Index of scoped AGENTS.md".
# validate-structure.sh must accept BOTH so a freshly generated root does not
# fail the skill's own structure validation, while a bloated root without any
# scope index still fails.
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPTS_DIR="$(dirname "$SCRIPT_DIR")"
GENERATE="$SCRIPTS_DIR/generate-agents.sh"
VALIDATE="$SCRIPTS_DIR/validate-structure.sh"
NEW_HEADING='## Scoped AGENTS.md (MUST read when working in these directories)'
LEGACY_HEADING='## Index of scoped AGENTS.md'
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
fail() { echo "❌ FAIL: $1"; exit 1; }
pass() { echo "✅ PASS: $1"; }
# Build a minimal repo with a scoped directory so the generated root exceeds
# 50 lines and includes a populated scope index.
build_fixture() {
local dir="$1"
rm -rf "$dir"
mkdir -p "$dir/src" "$dir/.github/workflows"
cat > "$dir/package.json" <<'JSON'
{ "name": "fixture", "version": "1.0.0", "scripts": { "test": "vitest", "build": "tsc" } }
JSON
echo "console.log('hi')" > "$dir/src/index.ts"
echo "name: ci" > "$dir/.github/workflows/ci.yml"
git -C "$dir" init -q
git -C "$dir" -c user.email=t@t.t -c user.name=t add -A
git -C "$dir" -c user.email=t@t.t -c user.name=t commit -qm init
}
# --- Test 1: generated root (new heading) passes validation -----------------
FX1="$WORK/new-heading"
build_fixture "$FX1"
bash "$GENERATE" "$FX1" --style=thin >/dev/null 2>&1 || fail "generate-agents.sh errored"
grep -qF "$NEW_HEADING" "$FX1/AGENTS.md" \
|| fail "generator no longer emits the expected heading: $NEW_HEADING"
lines=$(wc -l < "$FX1/AGENTS.md")
[ "$lines" -gt 50 ] || fail "generated root is only $lines lines; expected >50 to exercise the scope-index path"
if bash "$VALIDATE" "$FX1" >/dev/null 2>&1; then
pass "generated root ($lines lines, new heading) validates"
else
fail "validate-structure.sh rejected a freshly generated root (#55 regression)"
fi
# --- Test 2: legacy heading still accepted (backward compatibility) ----------
FX2="$WORK/legacy-heading"
cp -r "$FX1" "$FX2"
# Rewrite only the heading line, keeping the rest of the generated root intact.
# Use a temp file + mv rather than `sed -i` so the test stays portable across
# GNU sed (Linux) and BSD sed (macOS); this repo's CI also runs on macos-latest.
sed "s|^${NEW_HEADING}\$|${LEGACY_HEADING}|" "$FX2/AGENTS.md" > "$FX2/AGENTS.md.tmp"
mv "$FX2/AGENTS.md.tmp" "$FX2/AGENTS.md"
grep -qF "$LEGACY_HEADING" "$FX2/AGENTS.md" || fail "could not rewrite heading to legacy form"
if bash "$VALIDATE" "$FX2" >/dev/null 2>&1; then
pass "root with legacy heading still validates (backward compatible)"
else
fail "validate-structure.sh rejected the legacy scope-index heading"
fi
# --- Test 3: title-case heading (older generated roots) accepted (#81) -------
TITLE_HEADING='## Index of Scoped AGENTS.md'
FX4="$WORK/title-case-heading"
cp -r "$FX1" "$FX4"
# Temp file + mv keeps this portable across GNU and BSD sed (see Test 2).
sed "s|^${NEW_HEADING}\$|${TITLE_HEADING}|" "$FX4/AGENTS.md" > "$FX4/AGENTS.md.tmp"
mv "$FX4/AGENTS.md.tmp" "$FX4/AGENTS.md"
grep -qF "$TITLE_HEADING" "$FX4/AGENTS.md" || fail "could not rewrite heading to title-case form"
if bash "$VALIDATE" "$FX4" >/dev/null 2>&1; then
pass "root with title-case heading validates (#81)"
else
fail "validate-structure.sh rejected the title-case scope-index heading (#81 regression)"
fi
# --- Test 4: bloated root without any scope index still fails ----------------
FX3="$WORK/no-heading"
cp -r "$FX1" "$FX3"
# Drop the scope-index heading so the >50-line root has no index at all.
# Temp file + mv keeps this portable across GNU and BSD sed (see Test 2).
sed "/^${NEW_HEADING}\$/d" "$FX3/AGENTS.md" > "$FX3/AGENTS.md.tmp"
mv "$FX3/AGENTS.md.tmp" "$FX3/AGENTS.md"
if bash "$VALIDATE" "$FX3" >/dev/null 2>&1; then
fail "validate-structure.sh accepted a bloated root with no scope index"
else
pass "bloated root without a scope index is still rejected"
fi
echo "All scope-index heading regression tests passed."
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 469k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 197k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |