agentleFS
iushviushv/agentic-ai-skills/AGENTS.md

agentic-ai-skills

AGENTS.md1 starsChanged 4 months agoMITView on GitHub

Canonical source of truth. All tool-specific rule files are generated from this file. Run scripts/sync-rules.sh after editing. Run validate.sh to verify parity. Build production-grade agentic AI systems. Every decision optimizes for debuggability, safety, cost control, and graceful failure. Ship the simplest thing that works, then layer complexity only when measurably justified. All code is async-first Python 3.12+. Pick the simplest level that works. Most production systems are Level 1-3. Golden Rule: Start at Level 0. Move up only when the…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,691 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository6 other files it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

15 rules. About 1 is common, 11 are distinctive, and 3 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Golden Rule: Start at Level 0. Move up only when the current level demonstrably fails.

    line 23
  2. Distinctive:

    Never trust LLM output without validation against tool results and schemas.

    line 62
  3. Common:

    Never put credentials in prompts or memory.

    line 94
  4. Very specific:

    Use adaptive thinking (thinking={"type": "adaptive"}) with output_config.effort.

    line 118
  5. Very specific:

    Default effort to high; drop to medium/low for routine or latency-bound work.

    line 120
  6. Distinctive:

    Follow the test pyramid. Gate CI/CD on eval results.

    line 131
  7. Distinctive:

    Run every commit. Must cover: SQL safety blocks mutations, guardrails block injections, sandbox prevents network, memory enforces limits, …

    line 134
  8. Distinctive:

    Run every PR. Must cover: agent calls tools then answers, agent respects limits, fallback works on primary failure, output validation …

    line 138
  9. Distinctive:

    Verify: expected tools used, answer contains keywords, resource bounds met, no errors.

    line 142
  10. Distinctive:

    Eval gate: Every prompt or tool change must pass eval dataset before merge.

    line 144
  11. Very specific:

    Avoid these. Detailed diagnostics live in the agent-debug skill.

    line 148
  12. Distinctive:

    Add input guardrails — schema validation, injection detection.

    line 167
  13. Distinctive:

    Add output guardrails — PII scrubbing, schema validation, grounding.

    line 168
  14. Distinctive:

    Write unit tests — every tool, guardrail, parser (10+ each).

    line 172
  15. Distinctive:

    Write integration tests — mock LLM, test the loop.

    line 173

≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Agentic AI Production Rules

Canonical source of truth. All tool-specific rule files are generated from this file. Run scripts/sync-rules.sh after editing. Run validate.sh to verify parity.

Project Overview

Build production-grade agentic AI systems. Every decision optimizes for debuggability, safety, cost control, and graceful failure. Ship the simplest thing that works, then layer complexity only when measurably justified. All code is async-first Python 3.12+.

Architecture Rules

Pick the simplest level that works. Most production systems are Level 1-3.

  • Level 0 — Single LLM call. Use when no tools needed, single-turn.
  • Level 1 — Prompt chain. Use for fixed, predictable step sequences.
  • Level 2 — Router. Use when multiple known task types need specialized handlers.
  • Level 3 — Tool-using agent (ReAct). Use when tool selection is dynamic.
  • Level 4 — Multi-agent. Use only when agents need different permissions or models.
  • Level 5 — Autonomous. Use sparingly for open-ended exploration.

Golden Rule: Start at Level 0. Move up only when the current level demonstrably fails.

Decision path: no tools → L0/L1; fixed sequence → L1/L2; dynamic tools → L3; split permissions → L4; open-ended → L5.

Tool Design Rules

Tools determine agent quality more than prompts. Follow all six principles:

  1. Verb-noun names — run_sql, create_chart, not do_stuff.
  2. Rich descriptions — State WHEN to use, WHAT it returns, and edge cases.
  3. Constrained parameters — Use enums, patterns, min/max. No unconstrained strings.
  4. Small and focused — 10 small tools > 3 god-tools. Limit 3-7 tools per agent.
  5. Idempotent — Safe to retry without side effects where possible.
  6. Structured output — Return typed data, not free-form text. Enforce it with output_config.format (JSON schema) or strict: true on the tool definition.

Expose tools via MCP (Model Context Protocol) for cross-platform interoperability. Past ~10 tools, defer loading and let tool search surface the relevant few per turn rather than splitting the work across more agents.

Safety Rules

Apply defense-in-depth. Every request passes through a 6-layer pipeline:

Input layers:

  1. Schema validation — Pydantic models, length limits, type checks.
  2. Content filtering — Regex for injection patterns, encoding normalization.
  3. ML classification — Prompt injection detector, toxicity filter.
  4. Semantic analysis — Intent classification, data exfiltration detection.

Processing layers: 5. Tool guardrails — Per-tool permissions, sandboxed execution, argument validation. 6. Output guardrails — PII scrubbing, schema validation, hallucination grounding check.

Non-negotiable safety rules:

  • Detect and block: "ignore previous instructions", encoding bypass, HTML injection.
  • SQL tools: Allow only SELECT. Block INSERT, UPDATE, DELETE, DROP, ALTER, TRUNCATE.
  • Wrap all external content in <untrusted_content> markers.
  • Sandbox code execution: network=none, filesystem read-only, resource limits, non-root.
  • Never trust LLM output without validation against tool results and schemas.

Reliability Rules

Retry policy:

  • Exponential backoff with jitter: base_delay * 2^attempt, capped at max_delay.
  • Max 3 attempts. Only retry transient errors: timeout, 429, 5xx, connection.

Circuit breaker:

  • Track failures per provider. Open after 3 consecutive failures.
  • Cooldown 30 seconds. Half-open allows one probe request. Success resets counter.

Model fallback chain:

  • Primary → Fallback 1 → Fallback 2. Skip providers with open circuits.

Graceful degradation levels:

  1. Full agent with all tools.
  2. Agent without code execution.
  3. Direct LLM response, no tools.
  4. Cached response for similar queries.
  5. Polite error message with recovery ETA.

Dead letter queue:

  • Store failed tasks for manual review and replay. Alert if DLQ > 50 items.

Context Rules

  • Compaction — summarize earlier turns as context fills. Append the full response content back, not just the text, or the compaction state is lost.
  • Context editing — clear stale tool results and thinking blocks when old outputs are no longer relevant, instead of summarizing them.
  • Memory — persist learnings to files for anything that must survive the session.
  • Never put credentials in prompts or memory. Both persist in history and replay.

Observability Rules

Trace every span. Emit structured events for: run start/end, LLM call/response, tool call/result, guardrail checks, errors. Use Langfuse or LangSmith.

Five alert rules:

  1. HighErrorRate — failures/total > 10% for 5 min → CRITICAL.
  2. CostSpike — cost > $10/hour → WARNING.
  3. HighLatency — P95 > 60s for 10 min → WARNING.
  4. AllProvidersDown — All LLM circuits open → CRITICAL.
  5. DLQGrowing — Dead letter queue > 50 items → WARNING.

Cost Rules

Per-request budgets (enforce before every LLM call):

  • max_cost_usd: default $0.50.
  • max_tokens: default 100,000.
  • max_iterations: default 10, hard cap 50.
  • timeout_seconds: default 120, hard cap 600.
  • Truncate large tool outputs at 10,000 chars.

Reasoning depth:

  • Use adaptive thinking (thinking={"type": "adaptive"}) with output_config.effort. A fixed budget_tokens is removed on current models and returns a 400.
  • Default effort to high; drop to medium/low for routine or latency-bound work.
  • Give agentic loops a task_budget so the model paces itself. max_tokens truncates mid-thought; a task budget lets it finish gracefully.

Three caching strategies:

  1. Exact cache — Same question → same answer. TTL 1 hour.
  2. Semantic cache — Similarity > 0.95 → cached answer.
  3. Prompt cache — Mark stable system prompt with cache_control. 90% cost reduction.

Testing Rules

Follow the test pyramid. Gate CI/CD on eval results.

Unit tests (10+ per component): Tools, guardrails, parsers, memory. Run every commit. Must cover: SQL safety blocks mutations, guardrails block injections, sandbox prevents network, memory enforces limits, each tool works in isolation.

Integration tests (3-5): Mock LLM agent loop, tool chaining, fallback logic. Run every PR. Must cover: agent calls tools then answers, agent respects limits, fallback works on primary failure, output validation catches issues.

E2E golden trajectories (5-10): Real LLM calls. Run nightly or pre-release. Verify: expected tools used, answer contains keywords, resource bounds met, no errors.

Eval gate: Every prompt or tool change must pass eval dataset before merge.

Anti-Patterns

Avoid these. Detailed diagnostics live in the agent-debug skill.

  • Premature multi-agent — Use single agent with good tools first.
  • God Agent — Keep 3-7 tools per agent, not 20+.
  • No iteration limits — Always set max_iterations, max_tokens, max_cost.
  • LLM for everything — Use code for precision, LLM for judgment.
  • Raw API exposure — Wrap APIs in focused tool interfaces.
  • Fire-and-forget — Trace every step, alert on anomalies.
  • Trust the output — Validate against tool results and schemas.
  • Monolithic prompt — Assemble prompts dynamically per context.
  • No fallbacks — Always implement fallback chain + circuit breaker.
  • Skipping eval — Gate CI/CD on eval for every change.

Quick-Start Checklist

  1. Define scope — what agent can and cannot do.
  2. Pick architecture level 0-5 (start at 0).
  3. Design tools first — clear schemas, rich descriptions, focused scope.
  4. Set all limits — max_iterations, max_tokens, max_cost, timeout.
  5. Add input guardrails — schema validation, injection detection.
  6. Add output guardrails — PII scrubbing, schema validation, grounding.
  7. Sandbox code execution — network=none, memory limits, non-root.
  8. Implement retry + fallback — exponential backoff, circuit breaker, model fallback.
  9. Trace everything — LLM calls, tool calls, decisions.
  10. Write unit tests — every tool, guardrail, parser (10+ each).
  11. Write integration tests — mock LLM, test the loop.
  12. Build eval dataset — 10+ golden trajectories, grow from production failures.
  13. Set up metrics — error rate, latency, cost, tool calls per run.
  14. Set up alerts — error spike, cost spike, latency, provider outage.
  15. Version prompts — store in YAML, review in PRs, gate on eval.
  16. Plan for incidents — DLQ, graceful degradation, runbook.
  17. Deploy with canary — progressive rollout with auto-rollback.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.