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-command-allowlist.sh
View on GitHub#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Netresearch DTT GmbH
# Regression test for the smoke-test allowlist in verify-commands.sh (issue #104).
#
# is_safe_command() matched the first word of a command and the runner then
# passed the whole string to `bash -c`, so "git status; touch PWNED" was
# approved on its prefix and both halves ran. Commands carrying shell syntax
# are now rejected outright.
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPTS_DIR="$(dirname "$SCRIPT_DIR")"
VERIFY="$SCRIPTS_DIR/verify-commands.sh"
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
fail() { echo "❌ FAIL: $1"; exit 1; }
pass() { echo "✅ PASS: $1"; }
write_agents() {
local dir="$1" cmd="$2"
mkdir -p "$dir"
cat > "$dir/AGENTS.md" <<AGENTS
# Fixture
## Commands
| Command | Purpose |
|---------|---------|
| \`$cmd\` | fixture |
AGENTS
}
# --- Test 1: a chained command does not run, and is not reported as working
FX="$WORK/chained"
write_agents "$FX" "git status; touch $FX/PWNED"
OUT="$(cd "$FX" && SMOKE_TEST=true bash "$VERIFY" . 2>&1)" || true
[ -e "$FX/PWNED" ] && fail "the chained command executed — allowlist bypassed"
grep -q "Not smoke-tested" <<<"$OUT" || fail "chained command was not reported as skipped (output was: $OUT)"
pass "chained command neither runs nor counts as verified"
# --- Test 2 (companion): a plain allowlisted command still runs
# Without this the test above would also pass if everything were rejected.
FX="$WORK/plain"
write_agents "$FX" "git --version"
OUT="$(cd "$FX" && SMOKE_TEST=true bash "$VERIFY" . 2>&1)" || true
grep -q "command works" <<<"$OUT" || fail "plain allowlisted command was not executed (output was: $OUT)"
pass "plain allowlisted command is still smoke-tested"
# --- Test 3: the predicate itself, per shell construct
eval "$(awk '/^is_safe_command\(\) \{/,/^\}/' "$VERIFY")"
eval "$(awk '/^has_safe_arguments\(\) \{/,/^\}/' "$VERIFY")"
expect() {
local cmd="$1" want="$2" got
if is_safe_command "$cmd"; then got=allow; else got=reject; fi
[ "$got" = "$want" ] || fail "is_safe_command: want $want, got $got for <$cmd>"
}
expect 'git --version' allow
expect 'npm test' allow
expect 'make -n test' allow
expect 'vendor/bin/phpunit --filter Foo' allow
expect './gradlew build' allow
expect 'git status; touch /tmp/x' reject # separator
expect 'npm test && curl http://x' reject # conjunction
expect 'npm test | sh' reject # pipe
# The next two are deliberately single-quoted: the point is that the predicate
# sees the substitution syntax literally, so it must not expand here.
# shellcheck disable=SC2016
expect 'echo $(id)' reject # substitution
# shellcheck disable=SC2016
expect 'git log `id`' reject # legacy substitution
expect 'npm test > /tmp/out' reject # redirection
expect 'bash -n scripts/*.sh' reject # glob
expect 'rm -rf /' reject # not on the allowlist
expect 'curl http://example.com' reject # network fetch, deliberately dropped
pass "is_safe_command rejects every shell construct that can chain a command"
# --- Test 4: the first word alone decides nothing.
# git and docker/podman are smoke-tested only in informational forms. Inspection
# tools whose own options can run a program or write a file are not smoke-tested
# at all; a blocklist of their options would always miss one.
expect 'git status' reject # reads repository config that can name commands
expect 'git -c core.pager=x log' reject # config on the command line
expect 'git version' allow
expect 'docker ps' allow
expect 'docker run alpine touch x' reject
expect 'podman -H tcp://x ps' reject
expect 'find . -name x' reject
expect 'rg TODO src' reject
expect 'rg --hostname-bin=./x foo' reject
expect 'ag TODO' reject
expect 'yq .a f.yaml' reject
expect 'file -C -m m' reject
expect 'sed -n p README.md' reject
expect 'awk -f x.awk README.md' reject
expect 'sort -o out README.md' reject
expect 'grep -n TODO README.md' allow
expect 'cat README.md' allow
expect 'jq . package.json' allow
expect 'ls -la' allow
pass "is_safe_command judges git and docker by their arguments and leaves out inspection tools that run programs"
# --- Test 5: the git case end to end. A repository's own config can name a
# command that `git status` runs; that command must not run.
FX="$WORK/git-config"
write_agents "$FX" "git status"
git -C "$FX" init -q
git -C "$FX" config core.fsmonitor "touch $FX/PWNED; false"
OUT="$(cd "$FX" && SMOKE_TEST=true bash "$VERIFY" . 2>&1)" || true
[ -e "$FX/PWNED" ] && fail "a command from the repository's git config ran during the smoke test"
pass "git status is not smoke-run in the analysed repository"
echo ""
echo "All command allowlist 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: 467k | 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: 196k | 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: 196k | 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: 196k | Updated | Claude CodeCodex | Verified | Install |