[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71D8W0R9KHNDWENR0RWVE3X":3,"skill-same:01M71D8W0R9KHNDWENR0RWVE3X":87},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":60,"commitSha":61,"skillDirectory":62,"forksCount":63,"repositoryHtmlUrl":64,"repositoryHomepageUrl":6,"ownerHtmlUrl":65,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":66,"install":67,"resources":80},"01M71D8W0R9KHNDWENR0RWVE3X","best-practices-agent",null,"Non-negotiable agent behavior rules. Covers: no silent failures, no error bypassing, no raw AQL, no direct imports, no parallel infrastructure, no swallowed exceptions, use existing skills, fix errors don't dodge them, transparency in verdicts.","cateyephotos\u002Fagent-skills","cateyephotos","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F110843613?v=4","01M71CCSDD8VJ7CZ4V1QQGBMA7","01M71CCSE1VRT329KB810CRC0V",0,"MIT","https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbest-practices-agent\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"best practices","best practices agent","best-practices","python","aql","recurring","do","parallel","infrastructure","patterns","direct","agent rules","transparency","anti-patterns","imports","resilience","errors","fix","memory","error","2026-11-10 10:12:30",false,"---\nname: best-practices-agent\ndescription: >\n  Non-negotiable agent behavior rules. Covers: no silent failures, no error bypassing,\n  no raw AQL, no direct imports, no parallel infrastructure, no swallowed exceptions,\n  use existing skills, fix errors don't dodge them, transparency in verdicts.\ntriggers:\n  - best practices agent\n  - agent rules\n  - agent behavior\n  - what not to do\n  - recurring violations\n  - agent anti-patterns\n  - silent failures\n  - error handling rules\n  - bypass errors\nlicense: MIT\ntaxonomy:\n  - precision\n  - resilience\nprovides:\n  - best-practices-agent\n  - skill-validation\ncomposes:\n  - best-practices-arangodb\n  - best-practices-python\n  - best-practices-skills\n  - memory\n---\n\n> STOP. READ THIS ENTIRE SKILL.MD BEFORE CALLING ANY ENDPOINT.\n\n# Agent Best Practices (NON-NEGOTIABLE)\n\nThese rules exist because agents violate them **every session**. Each rule below was\nwritten after the user corrected the same mistake multiple times. Breaking any of\nthese rules erodes trust and wastes the user's time.\n\n**Load this skill at the start of every session. No exceptions.**\n\n## The Meta-Rule\n\n> When you find an error, **FIX IT**. Do not work around it, do not swallow it,\n> do not pretend it didn't happen. The user would rather you spend 10 minutes\n> fixing a root cause than 2 minutes bypassing it and creating a landmine.\n\n---\n\n## Rule 1: No Silent Failures — `agent-no-silent-failures`\n\n**Severity: CRITICAL**\n\nNEVER swallow exceptions, return empty results on error, or hide failures behind\nfallback paths. If something fails, the user MUST know.\n\n### Bad patterns (BANNED)\n\n```python\n# BAD: Silent swallow\ntry:\n    result = client.recall(q=query)\nexcept Exception:\n    result = []  # ← User never knows it failed\n\n# BAD: Degraded fallback that hides the real problem\ntry:\n    result = daemon_call(\"\u002Frecall\", {\"q\": query})\nexcept ConnectionError:\n    result = bm25_only_fallback(query)  # ← Masks broken daemon\n\n# BAD: Return empty instead of raising\ndef get_controls(ids):\n    try:\n        return db.collection(\"sparta_controls\").get_many(ids)\n    except Exception:\n        return {}  # ← Caller thinks there are no controls\n\n# BAD: except: pass\ntry:\n    important_operation()\nexcept:\n    pass\n```\n\n### Good patterns (REQUIRED)\n\n```python\n# GOOD: Raise with context\ntry:\n    result = client.recall(q=query)\nexcept Exception as exc:\n    raise RuntimeError(f\"Memory recall failed for '{query}': {exc}\") from exc\n\n# GOOD: Log AND raise\ntry:\n    resp = client.post(\"\u002Frecall\", json={\"q\": query})\n    resp.raise_for_status()\nexcept httpx.HTTPStatusError as exc:\n    logger.error(\"Daemon \u002Frecall returned %d: %s\", exc.response.status_code, exc.response.text)\n    raise\n\n# GOOD: Specific exception handling with clear action\ntry:\n    result = daemon_call(\"\u002Frecall\", {\"q\": query})\nexcept ConnectionError as exc:\n    raise RuntimeError(\n        \"Memory daemon is down. Start it: systemctl --user start embry-memory\"\n    ) from exc\n```\n\n### Why this matters\n\nSilent failures create **invisible bugs**. The agent reports success, the user moves on,\nand hours later discovers the data was never stored, the search never ran, or the\nvalidation never checked anything. The user has corrected this pattern dozens of times.\n\n---\n\n## Rule 2: Fix Errors, Don't Bypass Them — `agent-fix-not-bypass`\n\n**Severity: CRITICAL**\n\nWhen you encounter an error during your work, **STOP and fix it**. Do not:\n- Comment out the broken code and write a workaround\n- Add a try\u002Fexcept around it and continue\n- Skip the failing step and move to the next one\n- Add a `# TODO: fix this later` and proceed\n- Change the input to avoid triggering the bug\n\n### Bad patterns (BANNED)\n\n```python\n# BAD: Bypassing a broken import\n# from graph_memory.lessons.store import store_lesson  # ImportError\n# Workaround: inline the storage logic\ndef store_lesson_inline(doc):\n    db.collection(\"lessons\").insert(doc)  # ← Lost all validation\n\n# BAD: Skipping a failing test instead of fixing the code\n@pytest.mark.skip(reason=\"flaky, will fix later\")\ndef test_critical_feature():\n    ...\n\n# BAD: Changing input to avoid the bug\n# Original: process_all_documents(docs)\n# Error: crashes on docs with unicode\nprocess_all_documents([d for d in docs if d.isascii()])  # ← Data loss\n```\n\n### Good patterns (REQUIRED)\n\n```python\n# GOOD: Diagnose the import error\n# ImportError: cannot import 'store_lesson' from 'graph_memory.lessons.store'\n# Investigation: function was renamed to 'store_lesson_v2' in commit abc123\n# Fix: update the import\nfrom graph_memory.lessons.store import store_lesson_v2 as store_lesson\n\n# GOOD: Fix the flaky test\ndef test_critical_feature():\n    # Was flaky because of race condition in teardown\n    # Fix: use fresh DB connection per test\n    with fresh_db_connection() as db:\n        ...\n\n# GOOD: Fix the unicode bug\ndef process_document(doc):\n    # Was crashing on unicode because of .encode('ascii')\n    # Fix: use utf-8\n    text = doc.encode('utf-8')\n    ...\n```\n\n### The STOP-INVESTIGATE-FIX pattern\n\n1. **STOP** — Don't write any more code\n2. **INVESTIGATE** — Read the error, find the root cause\n3. **FIX** — Fix the actual problem\n4. **VERIFY** — Confirm the fix works\n5. **RESUME** — Continue your original task\n\nIf you genuinely cannot fix it (e.g., requires infrastructure the user needs to set up),\n**tell the user explicitly** what's broken and what they need to do. Do NOT silently\nwork around it.\n\n---\n\n## Rule 3: No Raw AQL \u002F No Direct Imports — `agent-no-raw-aql`\n\n**Severity: CRITICAL**\n\nALL memory\u002Fdata access goes through the embry-memory daemon Unix socket. NEVER:\n\n- `from graph_memory import ...` (any submodule)\n- `from graph_memory.api import MemoryClient`\n- `from graph_memory.cli.query import ...`\n- `httpx.post(\"http:\u002F\u002F127.0.0.1:8529\u002F_db\u002Fmemory\u002F_api\u002Fcursor\", ...)`\n- `from arango import ArangoClient`\n- Any direct ArangoDB HTTP call\n\n### The ONLY correct pattern\n\n```python\nimport httpx\n\ntransport = httpx.HTTPTransport(uds=\"\u002Frun\u002Fuser\u002F1000\u002Fembry\u002Fmemory.sock\")\nclient = httpx.Client(transport=transport, base_url=\"http:\u002F\u002Flocalhost\", timeout=30.0)\n\n# Recall\nresp = client.post(\"\u002Frecall\", json={\"q\": \"my question\", \"limit\": 20})\n\n# Learn\nresp = client.post(\"\u002Flearn\", json={\"problem\": \"...\", \"solution\": \"...\"})\n\n# Taxonomy\nresp = client.post(\"\u002Ftaxonomy\u002Fcoverage\", json={\"collection\": \"lessons\"})\nresp = client.post(\"\u002Ftaxonomy\u002Funtagged\", json={\"collection\": \"lessons\", \"field\": \"bridge_attributes\"})\nresp = client.post(\"\u002Ftaxonomy\u002Fquery\", json={\"collection\": \"lessons\", \"filters\": {\"scope\": \"operational\"}})\nresp = client.post(\"\u002Ftaxonomy\u002Ftag\", json={\"collection\": \"lessons\", \"key\": \"abc\", \"bridge_attributes\": [\"Precision\"]})\nresp = client.post(\"\u002Ftaxonomy\u002Fbatch-tag\", json={\"collection\": \"lessons\", \"updates\": [...]})\n\n# Bulk key lookup\nresp = client.post(\"\u002Frecall\u002Fby-keys\", json={\"collection\": \"lessons\", \"keys\": [\"k1\", \"k2\"]})\n\n# Paginated listing\nresp = client.post(\"\u002Flist\", json={\"collection\": \"sparta_qra\", \"limit\": 50, \"offset\": 0})\n\n# Theory of Mind\nresp = client.get(\"\u002Ftom\u002Fgraham\")\nresp = client.post(\"\u002Ftom\u002Fgraham\u002Fevolve\", json={...})\n\n# Analytics\nresp = client.post(\"\u002Fanalytics\u002Frun\", json={...})\n```\n\n### If the daemon doesn't have an endpoint for what you need\n\n**STOP and tell the user.** Say: \"The daemon doesn't have an endpoint for X.\nShould I add one to the memory project's FastAPI app?\" Do NOT fall back to raw AQL.\n\n### Available daemon endpoints (complete list)\n\nCore: `\u002Frecall`, `\u002Flearn`, `\u002Frecall\u002Fby-keys`, `\u002Flist`\nTaxonomy: `\u002Ftaxonomy\u002Fcoverage`, `\u002Ftaxonomy\u002Fsample`, `\u002Ftaxonomy\u002Ftag`, `\u002Ftaxonomy\u002Fbatch-tag`, `\u002Ftaxonomy\u002Funtagged`, `\u002Ftaxonomy\u002Fquery`\nGraph: `\u002Frelated`, `\u002Fresidue`, `\u002Fadd-edge`, `\u002Fadd-edges`, `\u002Ftrace`\nToM: `\u002Ftom\u002F{user_id}`, `\u002Ftom\u002F{user_id}\u002Fevolve`, `\u002Ftom\u002F{user_id}\u002Fupdate-belief`\nIntent: `\u002Fclarify`, `\u002Fdeflect`, `\u002Fintent`\nAnalytics: `\u002Fanalytics\u002Frun`\nDrift: `\u002Fdrift`\nHealth: `\u002Fhealth`\n\n---\n\n## Rule 4: No Parallel Infrastructure — `agent-no-parallel-infra`\n\n**Severity: HIGH**\n\nBefore building ANYTHING new, check if it already exists. The #1 source of\narchitectural debt is agents creating parallel systems that duplicate existing skills.\n\n### Check BEFORE building\n\n| If you need... | Use this | NOT this |\n|----------------|----------|----------|\n| Semantic search | `\u002Fmemory recall` | New FAISS index |\n| Text search | `\u002Fmemory recall` (BM25 built-in) | Python whoosh\u002Ftantivy |\n| Tag extraction | `\u002Ftaxonomy` | New bridge extractor |\n| LLM completion | `\u002Fscillm` proxy (port 4001) | `openai.Client()` directly |\n| Prompt iteration | `\u002Fprompt-lab` | Hand-written prompts in code |\n| Entity extraction | `\u002Fextract-entities` | New regex classifier |\n| Web fetching | `\u002Ffetcher` | `requests.get()` with custom retry |\n| PDF extraction | `\u002Fextract-pdf` or `\u002Fextractor` | PyMuPDF inline |\n| Evidence cases | `\u002Fcreate-evidence-case` | Bespoke scoring script |\n| Formal proofs | `\u002Flean4-prove` | Raw curl to port 8604 |\n| Embeddings | Embedding service (port 8602) | Loading model in-process |\n| Code review | `\u002Freview-code` | Manual diff reading |\n\n### The anti-silo test\n\nBefore writing ANY new function, ask:\n1. Does a daemon endpoint already do this?\n2. Does a skill's `run.sh` already do this?\n3. Does a Python module in the project already do this?\n\nIf yes to any → **use it**. If no → ask the user before building it.\n\n---\n\n## Rule 5: No Swallowed HTTP Errors — `agent-no-swallowed-http`\n\n**Severity: HIGH**\n\nWhen calling any HTTP endpoint, ALWAYS check the response status. NEVER assume success.\n\n```python\n# BAD: Assumes success\nresp = client.post(\"\u002Frecall\", json={\"q\": query})\ndata = resp.json()  # ← Crashes with decode error on 500\n\n# BAD: Checks but ignores\nresp = client.post(\"\u002Frecall\", json={\"q\": query})\nif resp.status_code != 200:\n    return []  # ← Silent failure (Rule 1 violation too)\n\n# GOOD: Check and raise\nresp = client.post(\"\u002Frecall\", json={\"q\": query})\nif resp.status_code != 200:\n    raise RuntimeError(f\"Daemon \u002Frecall failed ({resp.status_code}): {resp.text}\")\ndata = resp.json()\n\n# ALSO GOOD: Use raise_for_status()\nresp = client.post(\"\u002Frecall\", json={\"q\": query})\nresp.raise_for_status()\ndata = resp.json()\n```\n\n---\n\n## Rule 6: No Reimplementing What Exists — `agent-no-reimplementation`\n\n**Severity: HIGH**\n\nThe codebase has solutions for common problems. Do NOT reimplement them.\n\n| Already exists | Location | Do NOT reimplement |\n|----------------|----------|--------------------|\n| Snowball stemming | ArangoDB `text_en` analyzer | Python stemming code |\n| Stop word removal | ArangoDB `text_en` analyzer | Python stopword lists |\n| BM25 scoring | ArangoDB `BM25()` function | Python TF-IDF |\n| Cosine similarity | ArangoDB `COSINE_SIMILARITY()` | Python numpy dot product |\n| Fuzzy matching | ArangoDB `LEVENSHTEIN_DISTANCE()` | Python editdistance |\n| Entity classification | `source_framework` field on `sparta_controls` | Regex-based framework guessing |\n| Bridge extraction | `\u002Ftaxonomy` skill | New keyword matching |\n| Domain terms | `domain_terms` collection | Hardcoded term lists |\n| Control lookup | `sparta_controls` collection | Hardcoded control maps |\n| Deduplication | `problem_hash` field + UPSERT | Python-side dedup |\n\n---\n\n## Rule 7: Memory First — `agent-memory-first`\n\n**Severity: HIGH**\n\nBefore scanning the codebase, before reading files, before grepping:\n\n```bash\n\u002Fmemory recall --q \"description of the problem\"\n```\n\nIf memory has the answer → use it. Do NOT scan the codebase redundantly.\nIf memory doesn't have it → solve it, then `\u002Fmemory learn` the solution.\n\nThis is not optional. This is THE workflow.\n\n---\n\n## Rule 8: Transparency in Verdicts — `agent-transparency`\n\n**Severity: HIGH**\n\nEvery verdict, assessment, or decision MUST show **WHY**, not just **WHAT**.\n\n```markdown\n# BAD: Opaque verdict\nResult: SATISFIED\n\n# GOOD: Transparent verdict\nResult: SATISFIED\nWhy: 3\u002F3 entities resolved (SV-AC-2 → 14 QRAs, CWE-89 → 8 QRAs, SV-CF-1 → 6 QRAs)\nGrounding: All entities confirmed in sparta_controls (8,979 total)\nTechnique bridge: SV-AC-2 and SV-CF-1 share technique T1548 (MITRE ATT&CK)\nWhat could be wrong: If the question assumes a relationship between AC-2 and CF-1\n  that doesn't exist, the technique bridge would be coincidental\n```\n\nThis applies to:\n- Evidence case verdicts\n- QRA quality assessments\n- Entity extraction results (show RESOLVED vs UNRESOLVED)\n- Any pass\u002Ffail gate\n\n---\n\nSee [RULES_EXTENDED.md](references\u002FRULES_EXTENDED.md) for rules 9-17 covering prompt usage, scillm, daemon endpoints, storage, error handling, response shapes, mandatory skill chains, memory reading, and service-first architecture.\n\n---\n\n# BAD: Inline prompt\nresp = scillm_call(\"You are a helpful assistant. Classify this text...\")\n\n# GOOD: Prompt from \u002Fprompt-lab with version tracking\nresp = scillm_call(load_prompt(\"classify_text_v3\"))\n```\n\n---\n\n# BAD\nfrom openai import OpenAI\nclient = OpenAI(api_key=os.getenv(\"OPENAI_API_KEY\"))\n\n# GOOD\nimport httpx\nresp = httpx.post(\n    \"http:\u002F\u002Flocalhost:4001\u002Fv1\u002Fchat\u002Fcompletions\",\n    headers={\"Authorization\": \"Bearer sk-dev-proxy-123\"},\n    json={\"model\": \"text\", \"messages\": [...]}\n)\n```\n\nThe proxy handles cascading, retries, budget tracking, and JSON validation.\n\n---\n\n# BAD: Over-engineered — masks every possible bug\ntry:\n    step1()\n    step2()\n    step3()\n    step4()\nexcept Exception as e:\n    logger.warning(f\"Something failed: {e}\")\n    return default_result\n\n# GOOD: Let unexpected errors propagate\nstep1()\nstep2()\ntry:\n    step3()  # This one has a known failure mode we can handle\nexcept ConnectionError as exc:\n    raise RuntimeError(\"Database unreachable for step 3\") from exc\nstep4()\n```\n\n---\n\n# BAD: Assumes shape\ndata = resp.json()\nitems = data[\"results\"]  # ← KeyError if API returned error JSON\n\n# GOOD: Validate shape\ndata = resp.json()\nif \"results\" not in data:\n    raise ValueError(f\"Unexpected response shape: {list(data.keys())}\")\nitems = data[\"results\"]\n```\n\n---\n\n## Quick Reference: The 5-Second Checklist\n\nBefore submitting ANY code, check:\n\n1. **Did I swallow any exceptions?** → If yes, add proper error handling\n2. **Did I bypass an error instead of fixing it?** → If yes, go fix the root cause\n3. **Did I import graph_memory directly?** → If yes, use the daemon socket\n4. **Did I build something that a skill already does?** → If yes, use the skill\n5. **Does my output show WHY, not just WHAT?** → If no, add reasoning\n\n---\n\n## Enforcement\n\nThese rules are enforced by:\n- **PostToolUse hooks** in `~\u002F.claude\u002Fsettings.json` (block specific patterns)\n- **Code review** via `\u002Freview-code`\n- **Session-start memory** loading (this skill)\n- **User correction** (if you get corrected for the same thing twice, it goes in this file)\n\n# BAD: subprocess to a skill with an HTTP service\nsubprocess.run([\"taxonomy\u002Frun.sh\", \"extract\", \"--text\", text])\nsubprocess.run([\"embedding\u002Frun.sh\", \"--text\", text])\nsubprocess.run([\"doc2qra\u002Frun.sh\", \"--input\", file])\n\n# GOOD: HTTP to the service\nhttpx.post(\"http:\u002F\u002Flocalhost:8601\u002Ftaxonomy\u002Ftag\", json={\"text\": text})\nhttpx.post(\"http:\u002F\u002Flocalhost:8602\u002Fembed\u002Fbatch\", json={\"texts\": texts})\nbatch_sync(requests, caller=\"my-skill\")  # chutes-call client\n```\n\n### `\u002Fskills-ci` enforcement\n\n`skills-ci` scans for `subprocess.service_bypass` violations — subprocess calls\nto skills that have HTTP services. This catches the pattern at static analysis time.\n\n### Why this rule exists\n\nGraham has corrected this pattern 3+ times. The learn-datalake fork bomb incident\n(79 extractors, 141 GB RSS) was a direct consequence of subprocess spawning without\nservice-level concurrency control.\n\n---\n","> STOP. READ THIS ENTIRE SKILL.MD BEFORE CALLING ANY ENDPOINT.\n\n# Agent Best Practices (NON-NEGOTIABLE)\n\nThese rules exist because agents violate them **every session**. Each rule below was\nwritten after the user corrected the same mistake multiple times. Breaking any of\nthese rules erodes trust and wastes the user's time.\n\n**Load this skill at the start of every session. No exceptions.**\n\n## The Meta-Rule\n\n> When you find an error, **FIX IT**. Do not work around it, do not swallow it,\n> do not pretend it didn't happen. The user would rather you spend 10 minutes\n> fixing a root cause than 2 minutes bypassing it and creating a landmine.\n\n---\n\n## Rule 1: No Silent Failures — `agent-no-silent-failures`\n\n**Severity: CRITICAL**\n\nNEVER swallow exceptions, return empty results on error, or hide failures behind\nfallback paths. If something fails, the user MUST know.\n\n### Bad patterns (BANNED)\n\n```python\n# BAD: Silent swallow\ntry:\n    result = client.recall(q=query)\nexcept Exception:\n    result = []  # ← User never knows it failed\n\n# BAD: Degraded fallback that hides the real problem\ntry:\n    result = daemon_call(\"\u002Frecall\", {\"q\": query})\nexcept ConnectionError:\n    result = bm25_only_fallback(query)  # ← Masks broken daemon\n\n# BAD: Return empty instead of raising\ndef get_controls(ids):\n    try:\n        return db.collection(\"sparta_controls\").get_many(ids)\n    except Exception:\n        return {}  # ← Caller thinks there are no controls\n\n# BAD: except: pass\ntry:\n    important_operation()\nexcept:\n    pass\n```\n\n### Good patterns (REQUIRED)\n\n```python\n# GOOD: Raise with context\ntry:\n    result = client.recall(q=query)\nexcept Exception as exc:\n    raise RuntimeError(f\"Memory recall failed for '{query}': {exc}\") from exc\n\n# GOOD: Log AND raise\ntry:\n    resp = client.post(\"\u002Frecall\", json={\"q\": query})\n    resp.raise_for_status()\nexcept httpx.HTTPStatusError as exc:\n    logger.error(\"Daemon \u002Frecall returned %d: %s\", exc.response.status_code, exc.response.text)\n    raise\n\n# GOOD: Specific exception handling with clear action\ntry:\n    result = daemon_call(\"\u002Frecall\", {\"q\": query})\nexcept ConnectionError as exc:\n    raise RuntimeError(\n        \"Memory daemon is down. Start it: systemctl --user start embry-memory\"\n    ) from exc\n```\n\n### Why this matters\n\nSilent failures create **invisible bugs**. The agent reports success, the user moves on,\nand hours later discovers the data was never stored, the search never ran, or the\nvalidation never checked anything. The user has corrected this pattern dozens of times.\n\n---\n\n## Rule 2: Fix Errors, Don't Bypass Them — `agent-fix-not-bypass`\n\n**Severity: CRITICAL**\n\nWhen you encounter an error during your work, **STOP and fix it**. Do not:\n- Comment out the broken code and write a workaround\n- Add a try\u002Fexcept around it and continue\n- Skip the failing step and move to the next one\n- Add a `# TODO: fix this later` and proceed\n- Change the input to avoid triggering the bug\n\n### Bad patterns (BANNED)\n\n```python\n# BAD: Bypassing a broken import\n# from graph_memory.lessons.store import store_lesson  # ImportError\n# Workaround: inline the storage logic\ndef store_lesson_inline(doc):\n    db.collection(\"lessons\").insert(doc)  # ← Lost all validation\n\n# BAD: Skipping a failing test instead of fixing the code\n@pytest.mark.skip(reason=\"flaky, will fix later\")\ndef test_critical_feature():\n    ...\n\n# BAD: Changing input to avoid the bug\n# Original: process_all_documents(docs)\n# Error: crashes on docs with unicode\nprocess_all_documents([d for d in docs if d.isascii()])  # ← Data loss\n```\n\n### Good patterns (REQUIRED)\n\n```python\n# GOOD: Diagnose the import error\n# ImportError: cannot import 'store_lesson' from 'graph_memory.lessons.store'\n# Investigation: function was renamed to 'store_lesson_v2' in commit abc123\n# Fix: update the import\nfrom graph_memory.lessons.store import store_lesson_v2 as store_lesson\n\n# GOOD: Fix the flaky test\ndef test_critical_feature():\n    # Was flaky because of race condition in teardown\n    # Fix: use fresh DB connection per test\n    with fresh_db_connection() as db:\n        ...\n\n# GOOD: Fix the unicode bug\ndef process_document(doc):\n    # Was crashing on unicode because of .encode('ascii')\n    # Fix: use utf-8\n    text = doc.encode('utf-8')\n    ...\n```\n\n### The STOP-INVESTIGATE-FIX pattern\n\n1. **STOP** — Don't write any more code\n2. **INVESTIGATE** — Read the error, find the root cause\n3. **FIX** — Fix the actual problem\n4. **VERIFY** — Confirm the fix works\n5. **RESUME** — Continue your original task\n\nIf you genuinely cannot fix it (e.g., requires infrastructure the user needs to set up),\n**tell the user explicitly** what's broken and what they need to do. Do NOT silently\nwork around it.\n\n---\n\n## Rule 3: No Raw AQL \u002F No Direct Imports — `agent-no-raw-aql`\n\n**Severity: CRITICAL**\n\nALL memory\u002Fdata access goes through the embry-memory daemon Unix socket. NEVER:\n\n- `from graph_memory import ...` (any submodule)\n- `from graph_memory.api import MemoryClient`\n- `from graph_memory.cli.query import ...`\n- `httpx.post(\"http:\u002F\u002F127.0.0.1:8529\u002F_db\u002Fmemory\u002F_api\u002Fcursor\", ...)`\n- `from arango import ArangoClient`\n- Any direct ArangoDB HTTP call\n\n### The ONLY correct pattern\n\n```python\nimport httpx\n\ntransport = httpx.HTTPTransport(uds=\"\u002Frun\u002Fuser\u002F1000\u002Fembry\u002Fmemory.sock\")\nclient = httpx.Client(transport=transport, base_url=\"http:\u002F\u002Flocalhost\", timeout=30.0)\n\n# Recall\nresp = client.post(\"\u002Frecall\", json={\"q\": \"my question\", \"limit\": 20})\n\n# Learn\nresp = client.post(\"\u002Flearn\", json={\"problem\": \"...\", \"solution\": \"...\"})\n\n# Taxonomy\nresp = client.post(\"\u002Ftaxonomy\u002Fcoverage\", json={\"collection\": \"lessons\"})\nresp = client.post(\"\u002Ftaxonomy\u002Funtagged\", json={\"collection\": \"lessons\", \"field\": \"bridge_attributes\"})\nresp = client.post(\"\u002Ftaxonomy\u002Fquery\", json={\"collection\": \"lessons\", \"filters\": {\"scope\": \"operational\"}})\nresp = client.post(\"\u002Ftaxonomy\u002Ftag\", json={\"collection\": \"lessons\", \"key\": \"abc\", \"bridge_attributes\": [\"Precision\"]})\nresp = client.post(\"\u002Ftaxonomy\u002Fbatch-tag\", json={\"collection\": \"lessons\", \"updates\": [...]})\n\n# Bulk key lookup\nresp = client.post(\"\u002Frecall\u002Fby-keys\", json={\"collection\": \"lessons\", \"keys\": [\"k1\", \"k2\"]})\n\n# Paginated listing\nresp = client.post(\"\u002Flist\", json={\"collection\": \"sparta_qra\", \"limit\": 50, \"offset\": 0})\n\n# Theory of Mind\nresp = client.get(\"\u002Ftom\u002Fgraham\")\nresp = client.post(\"\u002Ftom\u002Fgraham\u002Fevolve\", json={...})\n\n# Analytics\nresp = client.post(\"\u002Fanalytics\u002Frun\", json={...})\n```\n\n### If the daemon doesn't have an endpoint for what you need\n\n**STOP and tell the user.** Say: \"The daemon doesn't have an endpoint for X.\nShould I add one to the memory project's FastAPI app?\" Do NOT fall back to raw AQL.\n\n### Available daemon endpoints (complete list)\n\nCore: `\u002Frecall`, `\u002Flearn`, `\u002Frecall\u002Fby-keys`, `\u002Flist`\nTaxonomy: `\u002Ftaxonomy\u002Fcoverage`, `\u002Ftaxonomy\u002Fsample`, `\u002Ftaxonomy\u002Ftag`, `\u002Ftaxonomy\u002Fbatch-tag`, `\u002Ftaxonomy\u002Funtagged`, `\u002Ftaxonomy\u002Fquery`\nGraph: `\u002Frelated`, `\u002Fresidue`, `\u002Fadd-edge`, `\u002Fadd-edges`, `\u002Ftrace`\nToM: `\u002Ftom\u002F{user_id}`, `\u002Ftom\u002F{user_id}\u002Fevolve`, `\u002Ftom\u002F{user_id}\u002Fupdate-belief`\nIntent: `\u002Fclarify`, `\u002Fdeflect`, `\u002Fintent`\nAnalytics: `\u002Fanalytics\u002Frun`\nDrift: `\u002Fdrift`\nHealth: `\u002Fhealth`\n\n---\n\n## Rule 4: No Parallel Infrastructure — `agent-no-parallel-infra`\n\n**Severity: HIGH**\n\nBefore building ANYTHING new, check if it already exists. The #1 source of\narchitectural debt is agents creating parallel systems that duplicate existing skills.\n\n### Check BEFORE building\n\n| If you need... | Use this | NOT this |\n|----------------|----------|----------|\n| Semantic search | `\u002Fmemory recall` | New FAISS index |\n| Text search | `\u002Fmemory recall` (BM25 built-in) | Python whoosh\u002Ftantivy |\n| Tag extraction | `\u002Ftaxonomy` | New bridge extractor |\n| LLM completion | `\u002Fscillm` proxy (port 4001) | `openai.Client()` directly |\n| Prompt iteration | `\u002Fprompt-lab` | Hand-written prompts in code |\n| Entity extraction | `\u002Fextract-entities` | New regex classifier |\n| Web fetching | `\u002Ffetcher` | `requests.get()` with custom retry |\n| PDF extraction | `\u002Fextract-pdf` or `\u002Fextractor` | PyMuPDF inline |\n| Evidence cases | `\u002Fcreate-evidence-case` | Bespoke scoring script |\n| Formal proofs | `\u002Flean4-prove` | Raw curl to port 8604 |\n| Embeddings | Embedding service (port 8602) | Loading model in-process |\n| Code review | `\u002Freview-code` | Manual diff reading |\n\n### The anti-silo test\n\nBefore writing ANY new function, ask:\n1. Does a daemon endpoint already do this?\n2. Does a skill's `run.sh` already do this?\n3. Does a Python module in the project already do this?\n\nIf yes to any → **use it**. If no → ask the user before building it.\n\n---\n\n## Rule 5: No Swallowed HTTP Errors — `agent-no-swallowed-http`\n\n**Severity: HIGH**\n\nWhen calling any HTTP endpoint, ALWAYS check the response status. NEVER assume success.\n\n```python\n# BAD: Assumes success\nresp = client.post(\"\u002Frecall\", json={\"q\": query})\ndata = resp.json()  # ← Crashes with decode error on 500\n\n# BAD: Checks but ignores\nresp = client.post(\"\u002Frecall\", json={\"q\": query})\nif resp.status_code != 200:\n    return []  # ← Silent failure (Rule 1 violation too)\n\n# GOOD: Check and raise\nresp = client.post(\"\u002Frecall\", json={\"q\": query})\nif resp.status_code != 200:\n    raise RuntimeError(f\"Daemon \u002Frecall failed ({resp.status_code}): {resp.text}\")\ndata = resp.json()\n\n# ALSO GOOD: Use raise_for_status()\nresp = client.post(\"\u002Frecall\", json={\"q\": query})\nresp.raise_for_status()\ndata = resp.json()\n```\n\n---\n\n## Rule 6: No Reimplementing What Exists — `agent-no-reimplementation`\n\n**Severity: HIGH**\n\nThe codebase has solutions for common problems. Do NOT reimplement them.\n\n| Already exists | Location | Do NOT reimplement |\n|----------------|----------|--------------------|\n| Snowball stemming | ArangoDB `text_en` analyzer | Python stemming code |\n| Stop word removal | ArangoDB `text_en` analyzer | Python stopword lists |\n| BM25 scoring | ArangoDB `BM25()` function | Python TF-IDF |\n| Cosine similarity | ArangoDB `COSINE_SIMILARITY()` | Python numpy dot product |\n| Fuzzy matching | ArangoDB `LEVENSHTEIN_DISTANCE()` | Python editdistance |\n| Entity classification | `source_framework` field on `sparta_controls` | Regex-based framework guessing |\n| Bridge extraction | `\u002Ftaxonomy` skill | New keyword matching |\n| Domain terms | `domain_terms` collection | Hardcoded term lists |\n| Control lookup | `sparta_controls` collection | Hardcoded control maps |\n| Deduplication | `problem_hash` field + UPSERT | Python-side dedup |\n\n---\n\n## Rule 7: Memory First — `agent-memory-first`\n\n**Severity: HIGH**\n\nBefore scanning the codebase, before reading files, before grepping:\n\n```bash\n\u002Fmemory recall --q \"description of the problem\"\n```\n\nIf memory has the answer → use it. Do NOT scan the codebase redundantly.\nIf memory doesn't have it → solve it, then `\u002Fmemory learn` the solution.\n\nThis is not optional. This is THE workflow.\n\n---\n\n## Rule 8: Transparency in Verdicts — `agent-transparency`\n\n**Severity: HIGH**\n\nEvery verdict, assessment, or decision MUST show **WHY**, not just **WHAT**.\n\n```markdown\n# BAD: Opaque verdict\nResult: SATISFIED\n\n# GOOD: Transparent verdict\nResult: SATISFIED\nWhy: 3\u002F3 entities resolved (SV-AC-2 → 14 QRAs, CWE-89 → 8 QRAs, SV-CF-1 → 6 QRAs)\nGrounding: All entities confirmed in sparta_controls (8,979 total)\nTechnique bridge: SV-AC-2 and SV-CF-1 share technique T1548 (MITRE ATT&CK)\nWhat could be wrong: If the question assumes a relationship between AC-2 and CF-1\n  that doesn't exist, the technique bridge would be coincidental\n```\n\nThis applies to:\n- Evidence case verdicts\n- QRA quality assessments\n- Entity extraction results (show RESOLVED vs UNRESOLVED)\n- Any pass\u002Ffail gate\n\n---\n\nSee [RULES_EXTENDED.md](references\u002FRULES_EXTENDED.md) for rules 9-17 covering prompt usage, scillm, daemon endpoints, storage, error handling, response shapes, mandatory skill chains, memory reading, and service-first architecture.\n\n---\n\n# BAD: Inline prompt\nresp = scillm_call(\"You are a helpful assistant. Classify this text...\")\n\n# GOOD: Prompt from \u002Fprompt-lab with version tracking\nresp = scillm_call(load_prompt(\"classify_text_v3\"))\n```\n\n---\n\n# BAD\nfrom openai import OpenAI\nclient = OpenAI(api_key=os.getenv(\"OPENAI_API_KEY\"))\n\n# GOOD\nimport httpx\nresp = httpx.post(\n    \"http:\u002F\u002Flocalhost:4001\u002Fv1\u002Fchat\u002Fcompletions\",\n    headers={\"Authorization\": \"Bearer sk-dev-proxy-123\"},\n    json={\"model\": \"text\", \"messages\": [...]}\n)\n```\n\nThe proxy handles cascading, retries, budget tracking, and JSON validation.\n\n---\n\n# BAD: Over-engineered — masks every possible bug\ntry:\n    step1()\n    step2()\n    step3()\n    step4()\nexcept Exception as e:\n    logger.warning(f\"Something failed: {e}\")\n    return default_result\n\n# GOOD: Let unexpected errors propagate\nstep1()\nstep2()\ntry:\n    step3()  # This one has a known failure mode we can handle\nexcept ConnectionError as exc:\n    raise RuntimeError(\"Database unreachable for step 3\") from exc\nstep4()\n```\n\n---\n\n# BAD: Assumes shape\ndata = resp.json()\nitems = data[\"results\"]  # ← KeyError if API returned error JSON\n\n# GOOD: Validate shape\ndata = resp.json()\nif \"results\" not in data:\n    raise ValueError(f\"Unexpected response shape: {list(data.keys())}\")\nitems = data[\"results\"]\n```\n\n---\n\n## Quick Reference: The 5-Second Checklist\n\nBefore submitting ANY code, check:\n\n1. **Did I swallow any exceptions?** → If yes, add proper error handling\n2. **Did I bypass an error instead of fixing it?** → If yes, go fix the root cause\n3. **Did I import graph_memory directly?** → If yes, use the daemon socket\n4. **Did I build something that a skill already does?** → If yes, use the skill\n5. **Does my output show WHY, not just WHAT?** → If no, add reasoning\n\n---\n\n## Enforcement\n\nThese rules are enforced by:\n- **PostToolUse hooks** in `~\u002F.claude\u002Fsettings.json` (block specific patterns)\n- **Code review** via `\u002Freview-code`\n- **Session-start memory** loading (this skill)\n- **User correction** (if you get corrected for the same thing twice, it goes in this file)\n\n# BAD: subprocess to a skill with an HTTP service\nsubprocess.run([\"taxonomy\u002Frun.sh\", \"extract\", \"--text\", text])\nsubprocess.run([\"embedding\u002Frun.sh\", \"--text\", text])\nsubprocess.run([\"doc2qra\u002Frun.sh\", \"--input\", file])\n\n# GOOD: HTTP to the service\nhttpx.post(\"http:\u002F\u002Flocalhost:8601\u002Ftaxonomy\u002Ftag\", json={\"text\": text})\nhttpx.post(\"http:\u002F\u002Flocalhost:8602\u002Fembed\u002Fbatch\", json={\"texts\": texts})\nbatch_sync(requests, caller=\"my-skill\")  # chutes-call client\n```\n\n### `\u002Fskills-ci` enforcement\n\n`skills-ci` scans for `subprocess.service_bypass` violations — subprocess calls\nto skills that have HTTP services. This catches the pattern at static analysis time.\n\n### Why this rule exists\n\nGraham has corrected this pattern 3+ times. The learn-datalake fork bomb incident\n(79 extractors, 141 GB RSS) was a direct consequence of subprocess spawning without\nservice-level concurrency control.\n\n---\n",{"name":5,"license":14,"composes":43,"provides":47,"taxonomy":49,"triggers":51,"description":59},[44,45,46,36],"best-practices-arangodb","best-practices-python","best-practices-skills",[5,48],"skill-validation",[50,33],"precision",[19,29,52,53,54,55,56,57,58],"agent behavior","what not to do","recurring violations","agent anti-patterns","silent failures","error handling rules","bypass errors","Non-negotiable agent behavior rules. Covers: no silent failures, no error bypassing, no raw AQL, no direct imports, no parallel infrastructure, no swallowed exceptions, use existing skills, fix errors don't dodge them, transparency in verdicts.\n","main","92d3cf5de96f8f7e1668e121e82a95faaa78a995","skills\u002Fbest-practices-agent",2,"https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002Fcateyephotos","2026-06-13 12:05:20",{"source":8,"skillName":5,"commands":68,"prompt":78,"zipAvailable":79},[69,72,75],{"tool":70,"command":71},"npx","npx skills add cateyephotos\u002Fagent-skills --skill best-practices-agent",{"tool":73,"command":74},"bunx","bunx skills add cateyephotos\u002Fagent-skills --skill best-practices-agent",{"tool":76,"command":77},"pnpm","pnpm dlx skills add cateyephotos\u002Fagent-skills --skill best-practices-agent","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbest-practices-agent\u002FSKILL.md",true,[81],{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002FNO_SIMULATED_REVIEW.md","REFERENCE","参考文档",4832,"https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbest-practices-agent\u002Freferences\u002FNO_SIMULATED_REVIEW.md",[88,113,135,159,181,198],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":38},"01M71DBADHWPBVJWYQT9VAD1XE","best-practices-streamdeck","Project-specific best practices for the Stream Deck control suite: icon format constraints, socket vs config boundaries, widget button lifecycle, page creation via build_page, ArangoDB fallback patterns, and NVIS palette compliance.","https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbest-practices-streamdeck\u002FSKILL.md",[],[18,95,96,97,98,99,100,101,102,103,104,105,20,106,107,108,109,110,111,112],"best practices streamdeck","creation","for","project","page","static","deck","socket","lifecycle","monitor","typer","icon","task","palette","control","native","via","build",{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":38},"01M71DARX9YN0QEXS6EM2C6E4X","best-practices-scillm","Error recovery and anti-patterns for scillm LLM proxy. Load this when scillm calls fail, timeout, or return unexpected results. Covers batch sizing, header requirements, model selection, and debugging workflow.","https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbest-practices-scillm\u002FSKILL.md",[],[120,18,121,37,122,123,124,125,126,127,128,129,130,31,131,132,27,133,134,97],"best practices scillm","scillm","processing","model","selection","model selection","error recovery","debugging","when","workflow","batch","rate","rate limit","limit","proxy",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":38},"01M71DAMV3PAAPBADP5EY1N61S","best-practices-rust","Repo-specific Rust best practices for agentic coding: thiserror + anyhow error handling, tokio async runtime, tracing for observability, clap for CLI, axum for HTTP, serde patterns, cargo workspace conventions, ownership and lifetimes, and idiomatic Rust 2024 edition patterns.","https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbest-practices-rust\u002FSKILL.md",[],[142,143,18,37,144,145,146,147,148,149,150,151,33,152,153,154,155,156,157,158],"rust","best practices rust","async runtime","tokio","performance","code review","2024","agentic","code","review","server","cli","axum","rust error handling","polars","rust best practices","tracing",{"skillNo":160,"name":161,"nameZh":6,"description":162,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":38},"01M71DACXQ43RCTYYCB8WB1KPG","react-native-skills","React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.","https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbest-practices-react\u002Fskills\u002Freact-native-skills\u002FSKILL.md",[],[166,167,110,168,169,170,171,97,146,172,173,174,175,176,177,128,18,178,179,180],"react","react native","react native skills","modules","platform","animations","vercel","implementing","triggers","use","react native components","apps","tasks","components","with",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":187,"publishedAt":38},"01M71DA9YZ05NTRPEK9JAX283K","react-best-practices","React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React\u002FNext.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.","https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbest-practices-react\u002Fskills\u002Freact-best-practices\u002FSKILL.md",[],[166,188,18,146,189,128,150,178,179,190,191,192,193,194,27,195,172,196,174,197],"react best practices","writing","data fetching","react components","next","refactoring","data","Optimization","guidelines","pages",{"skillNo":199,"name":200,"nameZh":6,"description":201,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":202,"categories":203,"keywords":204,"publishedAt":38},"01M71DA77CYKDT0Q7VAXG4Y9QW","composition-patterns","React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.","https:\u002F\u002Fgithub.com\u002Fcateyephotos\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbest-practices-react\u002Fskills\u002Fcomposition-patterns\u002FSKILL.md",[],[205,206,27,207,208,172,209,174,210,211,175,128,212,178,179,213,214,215,166,180],"Composition","composition patterns","react composition patterns","react 19","render","boolean","component architecture","reusable","architecture","react composition","api"]