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/extract-github-rulesets.sh
View on GitHub#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Netresearch DTT GmbH
# Extract GitHub repository rulesets (newer API, not just branch protection)
# Returns JSON with ruleset details for AGENTS.md generation
# Falls back gracefully if unavailable (no auth, not GitHub, no rulesets)
set -euo pipefail
# shellcheck source-path=SCRIPTDIR
# shellcheck disable=SC1091 # the pre-commit hook runs shellcheck without
# -x, so it cannot follow this source no matter how the path is written.
source "$(dirname "${BASH_SOURCE[0]}")/lib/git.sh"
PROJECT_DIR="${1:-.}"
cd "$PROJECT_DIR"
# Silent exit with empty JSON if prerequisites not met
bail() {
jq -n '{rulesets: [], merge_queue: false, required_checks: [], signed_commits: false}'
exit 0
}
# Check gh CLI available
command -v gh &>/dev/null || bail
# Check authenticated
gh auth status &>/dev/null 2>&1 || bail
# Check this is a git repo with a remote
REMOTE_URL=$(project_git remote get-url origin 2>/dev/null) || bail
# Check it's a GitHub repo
[[ "$REMOTE_URL" =~ github\.com ]] || bail
# Extract owner/repo from URL (handles both HTTPS and SSH)
OWNER_REPO=$(echo "$REMOTE_URL" | sed -E 's|.*github\.com[:/]([^/]+/[^/.]+)(\.git)?.*|\1|')
[[ -n "$OWNER_REPO" ]] || bail
# Fetch rulesets — may fail if no permission or no rulesets
RULESETS_RAW=$(gh api "repos/$OWNER_REPO/rulesets" 2>/dev/null) || bail
# Check if response is a valid array
echo "$RULESETS_RAW" | jq -e 'type == "array"' &>/dev/null || bail
RULESET_COUNT=$(echo "$RULESETS_RAW" | jq 'length')
if [ "$RULESET_COUNT" -eq 0 ]; then
bail
fi
# Track aggregate settings
HAS_MERGE_QUEUE=false
HAS_SIGNED_COMMITS=false
ALL_REQUIRED_CHECKS="[]"
RULESETS_JSON="[]"
for i in $(seq 0 $((RULESET_COUNT - 1))); do
RULESET_ID=$(echo "$RULESETS_RAW" | jq -r ".[$i].id")
RULESET_NAME=$(echo "$RULESETS_RAW" | jq -r ".[$i].name // \"unnamed\"")
RULESET_TARGET=$(echo "$RULESETS_RAW" | jq -r ".[$i].target // \"branch\"")
RULESET_ENFORCEMENT=$(echo "$RULESETS_RAW" | jq -r ".[$i].enforcement // \"disabled\"")
# Skip disabled rulesets
[ "$RULESET_ENFORCEMENT" = "disabled" ] && continue
# Fetch detailed ruleset info (includes rules array)
DETAIL=$(gh api "repos/$OWNER_REPO/rulesets/$RULESET_ID" 2>/dev/null) || continue
# Extract rule types from the rules array
RULE_TYPES=$(echo "$DETAIL" | jq -r '[.rules[]?.type // empty] | unique' 2>/dev/null) || RULE_TYPES="[]"
# Check for specific rule types
if echo "$RULE_TYPES" | jq -e 'index("merge_queue")' &>/dev/null; then
HAS_MERGE_QUEUE=true
fi
if echo "$RULE_TYPES" | jq -e 'index("required_signatures")' &>/dev/null; then
HAS_SIGNED_COMMITS=true
fi
# Extract required status checks
STATUS_CHECKS=$(echo "$DETAIL" | jq -r '
[.rules[]? | select(.type == "required_status_checks") |
.parameters.required_status_checks[]?.context // empty] | unique' 2>/dev/null) || STATUS_CHECKS="[]"
if [ "$STATUS_CHECKS" != "[]" ] && [ "$STATUS_CHECKS" != "null" ]; then
ALL_REQUIRED_CHECKS=$(echo "$ALL_REQUIRED_CHECKS" "$STATUS_CHECKS" | jq -s 'add | unique')
fi
# Add to rulesets array
RULESETS_JSON=$(echo "$RULESETS_JSON" | jq \
--arg name "$RULESET_NAME" \
--arg target "$RULESET_TARGET" \
--arg enforcement "$RULESET_ENFORCEMENT" \
--argjson rules "$RULE_TYPES" \
'. + [{name: $name, target: $target, enforcement: $enforcement, rules: $rules}]')
done
# Output final JSON
jq -n \
--argjson rulesets "$RULESETS_JSON" \
--argjson merge_queue "$HAS_MERGE_QUEUE" \
--argjson required_checks "$ALL_REQUIRED_CHECKS" \
--argjson signed_commits "$HAS_SIGNED_COMMITS" \
'{rulesets: $rulesets, merge_queue: $merge_queue, required_checks: $required_checks, signed_commits: $signed_commits}'
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 |