Signals to Claude Code context, with evidence

Cluster post-release signals from support, incidents, logs, PR reviews and agent sessions, and give each theme a confidence. Then route it to the artifact that fixes it: a CLAUDE.md line, a path-scoped rule, a skill, a hook, an eval case, an issue, or "investigate". Every proposal carries its evidence, is checked against the documented format, and isn't applied. The proposed hook and evals actually run. Session: Signal Clustering, CLAUDE.md and Rules, Skills and Evals.

  • Python 3.9+
  • standard library only
  • offline: samples/signals.jsonl (27 signals, illustrative)
  • reads common/samples/tiny-app
python3 delivery-5/signals_to_context.py

Each signal is one JSON line with id, source, date and text (required), plus optional severity and paths. Signals from agent_session and pr_review are about how Claude worked; the rest are about the product. A real version would pull these through MCP servers for your analytics, error tracker or issue tracker, then feed the same JSONL shape in.

┌────────────────────────────────────────────────────────────────────────────┐
│ Signals to context: post-release feedback -> Claude Code context proposals │
└────────────────────────────────────────────────────────────────────────────┘
[1] Signals: 27 from signals.jsonl, today = 2026-10-20
  by source: agent_session 8, incident 2, log 3, pr_review 7, support 7
  agent signals: 15 (agent_session + pr_review: how Claude worked)
[2] Clusters (single-link, Jaccard >= 0.2); confidence = 0.4 volume + 0.3 diversity + 0.3 recency
id  theme (top shared terms)    n  sources                  confidence   about  
──  ──────────────────────────  ─  ───────────────────────  ───────────  ───────
C1  case · code · lower         4  log,support              0.82 high    product
C2  card · charge · total       4  incident,log,support     0.92 high    product
C3  float · integer · math      4  agent_session,pr_review  0.82 high    agent  
C4  assertion · failing · test  3  agent_session,pr_review  0.74 high    agent  
C5  export · init · list        3  agent_session,pr_review  0.74 high    agent  
C6  rate · region · add         3  agent_session,pr_review  0.74 high    agent  
C7  tax · discount · computed   3  incident,log,support     0.84 high    product
C8  commit · id · message       2  agent_session,pr_review  0.66 medium  agent  
C9  client · email · font       1  support                  0.18 low     product
[3] Routing (first matching rule wins)
  C1 case · code · lower -> issue/spec (R6)
     why: the product is wrong, not the agent: write it up as an issue and a brief
     e.g. S-001: Discount code welcome10 typed in lower case is rejected at checkout.
  C2 card · charge · total -> issue/spec + eval case (R6)
     why: the product is wrong, not the agent: write it up as an issue and a brief; high-severity signals, so an eval case locks the fix
     e.g. S-018: receipt_total_mismatch receipt=1093 card_charge=1092 region=CA items=3 cent
  C3 float · integer · math -> hook + eval case (R2)
     why: CLAUDE.md line 19 already says 'All amounts are integer cents. Never introduce floats for money.' and Claude still breaks it. CLAUDE.md is context, not enforced configuration; a deterministic check is the next step. A permission rule can gate a tool or a path, not what the edit contains, so this is a hook; high-severity signals, so an eval case locks the fix
     e.g. S-009: PR #41 review: tax_for now uses round(subtotal * 0.0725), float math in pricing; integer cents only.
  C4 assertion · failing · test -> path-scoped rule + eval case (R3)
     why: every signal points under tests/: a rule with paths: loads only when Claude works there, instead of costing context in every session; high-severity signals, so an eval case locks the fix
     e.g. S-016: Test edited to match buggy output: the assertion changed from 73 to 72 so the failing test passes.
  C5 export · init · list -> hook (R2)
     why: CLAUDE.md line 21 already says 'Keep the public API in `tinyapp/__init__.py` in sync when adding functions.' and Claude still breaks it. CLAUDE.md is context, not enforced configuration; a deterministic check is the next step. A permission rule can gate a tool or a path, not what the edit contains, so this is a hook
     e.g. S-007: Claude added receipt_json() but forgot to add it to the export list in tinyapp/__init__.py.
  C6 rate · region · add -> skill (R1)
     why: people keep asking how to do this: a procedure Claude loads when the task comes up
     e.g. S-008: How do I add a new tax region? Claude asked where the WA tax rate lives, then guessed a rate.
  C7 tax · discount · computed -> eval case + issue/spec (R5)
     why: a product regression: lock it with a case that fails if it comes back, then fix it via an issue
     e.g. S-013: INC-91: tax computed on the subtotal before the discount after the cart refactor; regression since release 0.3.0.
  C8 commit · id · message -> CLAUDE.md line (R4)
     why: a short convention that applies to the whole project and isn't in CLAUDE.md yet
     e.g. S-025: Commit messages from Claude lack the ticket id prefix (CART-123: ...).
  C9 client · email · font -> investigate (R0)
     why: 1 signal(s), confidence 0.18 < 0.45
     e.g. S-027: The receipt font looks odd in my email client.
[4] Proposals written to delivery-5/out/proposals/ (nothing applied)
  CLAUDE.md.patch                      C8
  PROPOSALS.md                         index
  evals/float-money.json               C3
  evals/receipt-total.json             C2
  evals/tax-after-discount.json        C7
  evals/tests-integrity.json           C4
  hooks/context_checks.py              C3, C5
  hooks/settings_snippet.json          C3, C5
  issues/case-insensitive-codes.md     C1
  issues/receipt-total.md              C2
  issues/tax-after-discount.md         C7
  rules/tests.md                       C4
  skills/add-tax-region/SKILL.md       C6
[5] Validation: documented formats, and the proposed hook and evals run offline on a temp copy of tiny-app
    file                              check                                                    detail                                              
──  ────────────────────────────────  ───────────────────────────────────────────────────────  ────────────────────────────────────────────────────
ok  CLAUDE.md.patch                   CLAUDE.md stays under 200 lines                          27 -> 29 lines                                      
ok  CLAUDE.md.patch                   evidence in a block-level HTML comment                                                                       
ok  rules/tests.md                    frontmatter on line 1                                                                                        
ok  rules/tests.md                    only `paths:` frontmatter                                paths only                                          
ok  rules/tests.md                    paths: non-empty, relative globs                         tests/**/*.py                                       
ok  rules/tests.md                    body has at least one rule                                                                                   
ok  skills/add-tax-region/SKILL.md    frontmatter on line 1                                                                                        
ok  skills/add-tax-region/SKILL.md    documented fields only                                   name, description, when_to_use, metadata            
ok  skills/add-tax-region/SKILL.md    name = folder, kebab-case (lab rule)                     add-tax-region                                      
ok  skills/add-tax-region/SKILL.md    description+when_to_use <= 1536                          205 chars                                           
ok  skills/add-tax-region/SKILL.md    metadata is a map                                        evidence and confidence                             
ok  skills/add-tax-region/SKILL.md    SKILL.md under 500 lines                                 19 lines                                            
ok  hooks/settings_snippet.json       top-level `hooks` object                                                                                     
ok  hooks/settings_snippet.json       PostToolUse is a documented hook event                                                                       
ok  hooks/settings_snippet.json       command hook with a timeout                              matcher 'Edit|Write', timeout 30s                   
ok  hooks/context_checks.py           exports_in_sync: clean file -> quiet                     PostToolUse: success | proceeds                     
ok  hooks/context_checks.py           exports_in_sync: broken file -> block                    tinyapp/pricing.py: discount_label is public but mis
ok  hooks/context_checks.py           no_float_money: clean file -> quiet                      PostToolUse: success | proceeds                     
ok  hooks/context_checks.py           no_float_money: broken file -> block                     tinyapp/pricing.py:32: true division '/' (use // on 
ok  hooks/context_checks.py           edit outside checked paths -> quiet                      PostToolUse: success | proceeds                     
ok  hooks/context_checks.py           exports_in_sync: git repo via a symlinked path -> block  PostToolUse: success | decision=block | proceeds | C
ok  issues/case-insensitive-codes.md  evidence + draft criteria                                                                                    
ok  evals/receipt-total.json          task, graders, evidence                                                                                      
ok  evals/receipt-total.json          grader: the receipt's last line shows Cart.total         passes on today's code                              
ok  issues/receipt-total.md           evidence + draft criteria                                                                                    
ok  evals/float-money.json            task, graders, evidence                                                                                      
ok  evals/float-money.json            grader: unit tests pass                                  OK                                                  
ok  evals/float-money.json            grader: no float math in pricing or cart (hook -         context checks: clean                               
ok  evals/tests-integrity.json        task, graders, evidence                                                                                      
ok  evals/tests-integrity.json        grader: unit tests pass                                  OK                                                  
ok  evals/tests-integrity.json        grader: the number of assertions in tests/ never         passes on today's code                              
ok  evals/tax-after-discount.json     task, graders, evidence                                                                                      
ok  evals/tax-after-discount.json     grader: tax applies after the discount (CLAUDE.m         passes on today's code                              
ok  issues/tax-after-discount.md      evidence + draft criteria                                                                                    

8 theme(s) with proposals, 1 to investigate; 34/34 validation checks passed. Review delivery-5/out/proposals/PROPOSALS.md
  1. Confidence comes from volume, source diversity and recency, not from how loud one ticket is. The clustering is deterministic, so the same signals give the same themes.
  2. CLAUDE.md already says "Never introduce floats for money", and Claude still breaks it. A permission rule can't see what an edit contains, so this theme becomes a hook plus an eval case.
  3. Every signal in this theme points under tests/, so it becomes a rule with paths: that loads only when Claude works there, not a line every session pays for.
  4. People keep asking how to add a tax region. That's a procedure, so it becomes a skill Claude loads when the task comes up.
  5. One signal at 0.18 confidence earns an investigation, not an artifact.
  6. The proposed PostToolUse hook runs on a temp copy of tiny-app. It stays quiet on clean files and blocks the broken ones, including through a symlinked repo path.
  • --min-confidence 0.7: the commit-prefix theme (0.66) drops to investigate, leaving 7 themes with proposals and 2 to investigate.
  • --today 2026-12-31: recency goes to 0 for every theme, and four more themes drop to investigate (five in all). Old feedback should count for less.
  • --threshold 0.15: the float-money and tax-region themes merge into one 7-signal cluster, and the tax-region skill disappears. A looser cluster hides a distinct fix.
  • Run the proposed hook yourself. In a scratch copy of common/samples/tiny-app, change // 100 to / 100 in apply_discount(), then run python3 <labs>/delivery-5/out/proposals/hooks/context_checks.py --scan tinyapp/pricing.py from the copy. It prints tinyapp/pricing.py:32: true division '/' (use // on integer cents) and exits 1.
  • Break it: append a signal with no text to a copy of samples/signals.jsonl and pass it with --signals. The lab stops with exit 2 and names the line, for example error: sig.jsonl:28: missing text.
  • Route by who was wrong. Product signals become issues, briefs and eval cases. Agent signals become context or checks, in rising strength: a CLAUDE.md line, a path-scoped rule, a skill, then a hook when the line already exists and is still broken.
  • "Claude treats CLAUDE.md files as context, not enforced configuration" (memory). A rule that keeps getting broken needs a deterministic check.
  • The CLAUDE.md patch keeps its evidence in a block-level HTML comment. Those comments are stripped before CLAUDE.md reaches Claude's context, so the evidence costs nothing (how CLAUDE.md files load).
  • A PostToolUse "block" is feedback, not prevention: the edit has already happened, and Claude gets the reason next to the tool result (PostToolUse decision control).
  • Every eval grader passes on today's code. That's what a regression lock should do; it only fails if the bug comes back.

A decision log Claude Code can find

Keep product decisions (expand, revise, simplify, revert, investigate, stop) as JSONL, check the log, compare it with release outcomes, and render it where Claude Code will see it before it undoes a decision: one record per decision, a CLAUDE.md pointer, and a path-scoped rule. Session: Decisions and Intended versus Actual Outcomes.

  • Python 3.9+
  • standard library only
  • offline: samples/decisions.jsonl (8 decisions, some deliberately flawed)
  • samples/outcomes.json (illustrative metrics)
python3 delivery-5/decision_log.py

With no subcommand it runs check, recommend and render in turn. The metrics in outcomes.json are illustrative.

┌────────────────────────────────────────┐
│ Decision log: check, recommend, render │
└────────────────────────────────────────┘
[1] Check 8 decisions in decisions.jsonl (today = 2026-10-20)
id      title                                         decision     status      review by   check       
──────  ────────────────────────────────────────────  ───────────  ──────────  ──────────  ────────────
D-0001  Roll out the receipt CLI to every store       expand       superseded  2026-10-01  1 warning(s)
D-0002  Keep discount codes case-sensitive for now    investigate  accepted    2026-11-15  1 warning(s)
D-0003  Revert float-based tax rounding to integer c  revert       accepted    2026-12-01  1 warning(s)
D-0004  Simplify Cart: compute totals, never store t  simplify     accepted    2026-12-15  1 error(s)  
D-0005  Expand regional tax coverage to WA            expand       proposed    2026-11-30  2 error(s)  
D-0006  Limit the receipt CLI to CA stores until the  revise       accepted    2026-11-01  ok          
D-0007  Pause the loyalty points pilot                pause        accepted    -           3 error(s)  
D-0008  Cut the discount banner down to one line      simplify     proposed    2026-11-20  ok          
  WARNING D-0001: superseded by D-0006 but its status still says accepted
  WARNING D-0002: 3 newer signals match its topics (S-001, S-005, S-019): re-check the kill criterion: More than 3 support tickets a month about lower-case codes being rejected.
  WARNING D-0003: 4 newer agent signals match its topics (S-003, S-009, S-015, S-021): Claude keeps undoing it, so enforce it (see signals_to_context.py)
  ERROR D-0004: supersedes D-0009, which isn't in the log
  ERROR D-0005: no evidence: name the signals or metrics this decision rests on
  ERROR D-0005: no kill criterion: say what would make you reverse it
  ERROR D-0007: decision 'pause' isn't one of expand, revise, simplify, revert, investigate, stop (did you mean 'stop'?)
  ERROR D-0007: no kill criterion: say what would make you reverse it
  ERROR D-0007: no review_by date
  summary: 6 error(s), 3 warning(s)
[2] Recommend from outcomes.json (release 0.3.0); first matching rule wins
  R1 data quality off -> investigate · R2 too early -> investigate · R3 critical guardrail -> revert · R4 guardrail -> revise · R5 target met -> expand · R6 partial + costly -> simplify · R7 partial -> revise · R8 flat after 28 days -> stop · R9 -> investigate
feature             rule  recommend    confidence  the log                                                   
──────────────────  ────  ───────────  ──────────  ──────────────────────────────────────────────────────────
bulk-import         R1    investigate  medium      no decision recorded: see decision_drafts.jsonl           
cart                R4    revise       high        disagrees with D-0004 (simplify): record why, or re-decide
discount-banner     R6    simplify     high        agrees with D-0008 (still proposed: accept it)            
loyalty-points      R8    stop         high        D-0007 uses 'pause', not a decision type                  
receipt-cli         R3    revert       high        disagrees with D-0006 (revise): record why, or re-decide  
region-tax-display  R5    expand       high        no decision recorded: see decision_drafts.jsonl           
wa-tax-region       R2    investigate  low         disagrees with D-0005 (expand): record why, or re-decide  
  bulk-import: data quality is off (import events double-counted after the logging change on 2026-10-02); fix the measurement before trusting any metric
     evidence: metric:carts_imported_per_day 50 -> 140 (target 80)
  cart: guardrail orders_taxed_before_discount = 0.004 breaks its limit <= 0.0; the primary metric met its target
     evidence: metric:cart_state_bugs_per_week 4 -> 1 (target 1); metric:orders_taxed_before_discount 0.004 (limit <= 0.0); S-013; S-017; S-022
  discount-banner: checkout_conversion moved the right way (0.81 -> 0.814) but missed 0.83, and the feature is expensive to keep: keep the part that works
     evidence: metric:checkout_conversion 0.81 -> 0.814 (target 0.83); metric:checkout_errors_per_1k 1.1 (limit <= 2.0, critical)
  loyalty-points: weekly_signups_per_store is flat (12 -> 12.4, below the 2 minimum effect) after 42 days
     evidence: metric:weekly_signups_per_store 12 -> 12.4 (target 30)
  receipt-cli: critical guardrail receipt_mismatch_rate = 0.012 breaks its limit <= 0.0
     evidence: metric:orders_with_printed_receipt 0.0 -> 0.71 (target 0.6); metric:receipt_mismatch_rate 0.012 (limit <= 0.0, critical); S-002; S-006; S-011; S-018
  region-tax-display: tax_questions_per_1k_orders reached 4.2 (target 5.0) with every guardrail inside its limit
     evidence: metric:tax_questions_per_1k_orders 9.0 -> 4.2 (target 5.0); metric:receipt_print_ms_p95 210 (limit <= 300)
  wa-tax-region: too early: 6 days and 140 orders (need 14+ days and 200+ orders)
     evidence: metric:wa_orders_taxed_correctly 0.0 -> 0.97 (target 0.99); S-008; S-023; S-024
[3] Render to delivery-5/out/
  decisions/0001-roll-out-the-receipt-cli-to-every-store.md           D-0001 superseded
  decisions/0002-keep-discount-codes-case-sensitive-for-now.md        D-0002 accepted
  decisions/0003-revert-float-based-tax-rounding-to-integer-cents.md  D-0003 accepted
  decisions/0004-simplify-cart-compute-totals-never-store-them.md     D-0004 accepted
  decisions/0005-expand-regional-tax-coverage-to-wa.md                D-0005 proposed
  decisions/0006-limit-the-receipt-cli-to-ca-stores-until-the.md      D-0006 accepted
  decisions/0007-pause-the-loyalty-points-pilot.md                    D-0007 accepted
  decisions/0008-cut-the-discount-banner-down-to-one-line.md          D-0008 proposed
  decisions/README.md                                                 index
  decision_drafts.jsonl                                               6 draft(s) to review, then append to the log
  claude_md_pointer.md                                                4 lines for CLAUDE.md
  rules/decisions.md                                                  paths: 3 file(s); frontmatter ok
  Install: copy decisions/ to <repo>/docs/decisions/, paste claude_md_pointer.md into CLAUDE.md, and copy rules/decisions.md to <repo>/.claude/rules/.
  1. The table shows each decision's effective status. D-0006 superseded D-0001, but the log row for D-0001 still says accepted, so the check warns.
  2. Four newer agent signals match an accepted revert: Claude keeps undoing it. A decision that keeps being undone needs enforcement (see the signals lab above), not another reminder.
  3. "pause" isn't one of the six decision types, so the check rejects it and suggests stop. Fixed types are what make a log comparable with outcomes.
  4. Data quality is checked first. bulk-import has the best numbers and still gets "investigate", because its events were double-counted.
  5. A broken critical guardrail means revert, whatever the primary metric says. That disagrees with the log's D-0006, and the lab asks you to record why or decide again.
  6. Claude sees the decisions in two places: a 4-line CLAUDE.md section that points at docs/decisions/, and a .claude/rules/ file with paths: for the three files the decisions cover.
  • check --strict exits 1 (--strict: 6 error(s) in the log): a CI gate on the log file.
  • Fix one entry: in a copy of samples/decisions.jsonl, give D-0007 "decision": "stop", a real kill_criterion and a review_by date, then run check --log <copy>. D-0007's row turns ok, the summary drops to 3 error(s), 3 warning(s), and recommend --log <copy> now says the log "agrees with D-0007".
  • Open out/rules/decisions.md. Each covered file lists the decisions on it, with links to their records, so the pointers load only when Claude reads or edits one of those files.
  • Review out/decision_drafts.jsonl: 6 proposed drafts, one for each feature where the log has no valid decision or disagrees with the recommendation. Edit them, then append them to the log.
  • Every decision needs evidence, a kill criterion and a review date. Without a kill criterion, nobody knows what would reverse it.
  • The recommendation rules run in a fixed order: data quality, then exposure, then guardrails (critical means revert), and only then the primary metric.
  • The CLAUDE.md section points at the folder rather than @-importing it. Imports don't reduce context cost, because "imported files load together with the CLAUDE.md that imports them" (memory).
  • A path-scoped rule loads only when Claude works with a matching file, so the decision pointers cost context only where they apply.