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/lib/config-root.sh
View on GitHub#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Netresearch DTT GmbH
# Find nearest config root for a given stack type
# Find nearest directory containing package.json (for Node scopes)
# Usage: find_node_config_root "/path/to/scope"
# Returns: directory path or empty string
find_node_config_root() {
local start_dir="$1"
local search_dir="$start_dir"
while [[ "$search_dir" != "." && "$search_dir" != "/" ]]; do
if [[ -f "$search_dir/package.json" ]]; then
echo "$search_dir"
return 0
fi
search_dir=$(dirname "$search_dir")
done
# Check project root as fallback
if [[ -f "package.json" ]]; then
echo "."
return 0
fi
return 1
}
# Find nearest directory containing composer.json (for PHP scopes)
find_php_config_root() {
local start_dir="$1"
local search_dir="$start_dir"
while [[ "$search_dir" != "." && "$search_dir" != "/" ]]; do
if [[ -f "$search_dir/composer.json" ]]; then
echo "$search_dir"
return 0
fi
search_dir=$(dirname "$search_dir")
done
if [[ -f "composer.json" ]]; then
echo "."
return 0
fi
return 1
}
# Find nearest directory containing go.mod (for Go scopes)
find_go_config_root() {
local start_dir="$1"
local search_dir="$start_dir"
while [[ "$search_dir" != "." && "$search_dir" != "/" ]]; do
if [[ -f "$search_dir/go.mod" ]]; then
echo "$search_dir"
return 0
fi
search_dir=$(dirname "$search_dir")
done
if [[ -f "go.mod" ]]; then
echo "."
return 0
fi
return 1
}
# Find nearest directory containing pyproject.toml or setup.py (for Python scopes)
find_python_config_root() {
local start_dir="$1"
local search_dir="$start_dir"
while [[ "$search_dir" != "." && "$search_dir" != "/" ]]; do
if [[ -f "$search_dir/pyproject.toml" || -f "$search_dir/setup.py" ]]; then
echo "$search_dir"
return 0
fi
search_dir=$(dirname "$search_dir")
done
if [[ -f "pyproject.toml" || -f "setup.py" ]]; then
echo "."
return 0
fi
return 1
}
# Find Node workspace root (monorepo root)
# Detects: pnpm-workspace.yaml, package.json with "workspaces", lerna.json, nx.json
# Usage: find_node_workspace_root "/path/to/scope"
# Returns: workspace root directory or empty string
find_node_workspace_root() {
local start_dir="$1"
local search_dir="$start_dir"
while [[ "$search_dir" != "." && "$search_dir" != "/" ]]; do
# pnpm workspace
if [[ -f "$search_dir/pnpm-workspace.yaml" ]]; then
echo "$search_dir"
return 0
fi
# npm/yarn workspaces (package.json with "workspaces" field)
if [[ -f "$search_dir/package.json" ]]; then
if jq -e '.workspaces' "$search_dir/package.json" >/dev/null 2>&1; then
echo "$search_dir"
return 0
fi
fi
# Lerna monorepo
if [[ -f "$search_dir/lerna.json" ]]; then
echo "$search_dir"
return 0
fi
# Nx monorepo
if [[ -f "$search_dir/nx.json" ]]; then
echo "$search_dir"
return 0
fi
search_dir=$(dirname "$search_dir")
done
# Check project root as fallback
if [[ -f "pnpm-workspace.yaml" ]]; then
echo "."
return 0
fi
if [[ -f "package.json" ]] && jq -e '.workspaces' "package.json" >/dev/null 2>&1; then
echo "."
return 0
fi
if [[ -f "lerna.json" || -f "nx.json" ]]; then
echo "."
return 0
fi
return 1
}
# Extract Node version from nearest config
# Priority: package.json engines.node > .nvmrc > .node-version > .tool-versions
get_node_version() {
local config_root="$1"
local version=""
# Try package.json engines.node
if [[ -f "$config_root/package.json" ]]; then
version=$(jq -r '.engines.node // empty' "$config_root/package.json" 2>/dev/null)
[[ -n "$version" ]] && echo "$version" && return 0
fi
# Try .nvmrc
if [[ -f "$config_root/.nvmrc" ]]; then
version=$(tr -d '[:space:]' < "$config_root/.nvmrc")
[[ -n "$version" ]] && echo "$version" && return 0
fi
# Try .node-version
if [[ -f "$config_root/.node-version" ]]; then
version=$(tr -d '[:space:]' < "$config_root/.node-version")
[[ -n "$version" ]] && echo "$version" && return 0
fi
# Try .tool-versions (asdf)
if [[ -f "$config_root/.tool-versions" ]]; then
version=$(grep '^nodejs ' "$config_root/.tool-versions" 2>/dev/null | awk '{print $2}')
[[ -n "$version" ]] && echo "$version" && return 0
fi
return 1
}
# Extract JS framework from package.json dependencies
get_js_framework() {
local config_root="$1"
[[ ! -f "$config_root/package.json" ]] && return 1
local deps
deps=$(jq -r '(.dependencies // {}) + (.devDependencies // {}) | keys[]' \
"$config_root/package.json" 2>/dev/null)
# Check in priority order (more specific first)
echo "$deps" | grep -qw 'next' && echo "next.js" && return 0
echo "$deps" | grep -qw 'nuxt' && echo "nuxt" && return 0
echo "$deps" | grep -qw 'svelte' && echo "svelte" && return 0
echo "$deps" | grep -qw 'vue' && echo "vue" && return 0
echo "$deps" | grep -qw 'react' && echo "react" && return 0
echo "$deps" | grep -qw 'express' && echo "express" && return 0
return 1
}
# Check if TypeScript strict mode is enabled
get_ts_strict_mode() {
local config_root="$1"
[[ ! -f "$config_root/tsconfig.json" ]] && return 1
local strict
strict=$(jq -r '.compilerOptions.strict // false' "$config_root/tsconfig.json" 2>/dev/null)
[[ "$strict" == "true" ]] && echo "true" && return 0
return 1
}
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 |