- No hypotheses? Seeds them from CLAUDE.md.
- Hypotheses exist? Picks the most uncertain, designs an experiment, runs it.
- Evidence accumulating? Graduates proven rules, kills disproven ones.
- Everything tested? Reports and stops.
Rules that survive become convictions. Rules that fail become learnings.
```bash
agentdb hypothesis list 2>/dev/null
```
Decision tree (no human input needed):
1. No hypotheses table or empty? → go to SEED phase.
2. Hypotheses exist but all are unproven? → go to PICK phase.
3. Mix of tested/untested? → go to PICK phase (prioritize untested).
4. All have >= 3 experiments? → go to JUDGE phase.
5. Graduation/kill candidates exist? → go to EVOLVE phase.
Parse rule-like patterns:
- Imperative: "Always X", "Never Y", "Prefer Z", "Must W"
- Anti-patterns: block actions, "Don't", "Forbidden"
- Assertions: "X before Y", "X is better than Y"
- Quantitative claims: "reduces by X%", "takes N minutes"
- Conditional: "If X then Y", "When X, do Y"
For each rule:
```bash
agentdb hypothesis add "<statement>" --domain <auto-classify> --source "<file:line>"
```
Domain auto-classification by keyword:
- research, anti-pattern, prior work → methodology
- parallel, agent, spawn, tier → coordination
- test, coverage, edge case, mock → testing
- commit, branch, merge, PR → git
- secret, validation, auth, injection → security
- measure, optimize, latency, profile → performance
- Big 5, review, quality → quality
- module, interface, coupling → architecture
Deduplicate: skip if near-identical statement already exists.
Log count, then immediately proceed to PICK. No pause.
```bash
agentdb emit command "experiment-seed" "" '{"seeded":N}'
```
Priority order:
1. **Most uncertain**: confidence closest to 0.5 (maximum ignorance — any experiment is maximally informative)
2. **Least tested**: fewest total experiments (break ties)
3. **Highest impact domain**: methodology > coordination > security > testing > quality > git > architecture > performance
```sql
SELECT id, statement, domain, confidence, evidence_for + evidence_against as total_evidence
FROM hypotheses
WHERE status NOT IN ('graduated', 'refuted')
ORDER BY ABS(confidence - 0.5) ASC, total_evidence ASC
LIMIT 1;
```
**Falsifiability gate: if no possible outcome could refute the hypothesis, redesign.**
Every experiment defines BEFORE running: method, quantitative measurement, control
condition (what happens WITHOUT the rule), pass_criteria, fail_criteria.
Choose the LIGHTEST experiment type that produces signal:
1. **HISTORICAL** (cheapest — query existing data):
Query agentdb learnings, session outcomes, error patterns for evidence.
Use when: agentdb has >= 10 sessions or >= 20 learnings in the domain.
2. **COMPARATIVE** (medium — run a real task two ways):
Execute WITH the rule applied, then WITHOUT (or find prior without-cases).
Measure: time, error count, rework, quality.
3. **ABLATION** (medium — remove the rule, observe):
Temporarily ignore the rule during a real task. Record what breaks.
4. **OBSERVATIONAL** (passive — tag next N tasks):
Flag the hypothesis; future relevant tasks collect evidence passively.
Use when: active experimentation would be disruptive.
Minimum sample sizes: methodology/coordination/git/quality >= 3 comparisons;
testing >= 5 tasks per condition; security >= 50 fuzz inputs.
```bash
agentdb experiment add <H_ID> "<method>" "<measurement>" --pass-criteria "<criteria>"
```
**Gate: the control condition was actually tested, not just assumed.**
- HISTORICAL: query agentdb with specific SQL; evidence = query result + interpretation.
- COMPARATIVE: execute the task (spawn agents if needed); evidence = measured delta.
- ABLATION: execute with the rule explicitly ignored; evidence = observed difference.
- OBSERVATIONAL: record the flag; skip to next hypothesis (no blocking).
```bash
agentdb experiment verdict <EXP_ID> <supports|refutes|inconclusive> "<evidence summary>"
```
Confidence update (Bayesian, applied automatically by CLI):
- supports: confidence += (1 - confidence) * 0.25
- refutes: confidence -= confidence * 0.3
- inconclusive: no change
Evidence strings must be specific and measurable, never narrative.
Lifecycle transitions:
- unproven → testing: first experiment registered
- testing → supported: confidence >= 0.8 AND evidence_for >= 3 AND ratio >= 3:1
- testing → refuted: confidence < 0.2 AND evidence_against >= 2
- supported → graduated: human approval after sustained confidence
- refuted → killed: human approval to remove from rules
- any → unproven: rule is modified (resets all evidence)
```bash
agentdb learn pattern|failure "<what we learned>" "<evidence>"
agentdb emit command "experiment-conclude" "" '{"H":"ID","EXP":"ID","verdict":"X","confidence":0.XX}'
```
Loop back to PICK for next hypothesis.
```bash
agentdb hypothesis export
```
Write detailed report to _meta/research/experiment-report.md. Proceed to EVOLVE.
**Graduate** (confidence >= 0.8, evidence_for >= 3, ratio >= 3:1):
promote via the artifact ladder with human approval — hook if enforceable, agent if
a role, skill if methodology; CLAUDE.md prose only as last resort.
**Kill** (confidence < 0.2, evidence_against >= 2):
propose rule removal from CLAUDE.md (present to human).
**Mutate** (inconclusive after 5+ experiments):
the hypothesis may be poorly stated; propose a refined version as a NEW hypothesis,
linked to the original (evolution chain).
<ask_user>
Use AskUserQuestion ONCE at the end of the evolve phase:
Ask: "{graduated} rules proven, {killed} rules disproven, {mutated} rules refined. Apply changes?"
Options: apply all, review individually, skip for now
</ask_user>
```bash
agentdb emit command "experiment-evolve" "" '{"graduated":N,"killed":N,"mutated":N}'
```
1---2name: experiment3description: "Experiment engine for development rules. Treats rules as hypotheses, designs falsifiable tests, updates confidence, and graduates or kills rules. Triggers: experiment, hypothesis, prove, test rule, validate methodology, scientific, evidence."4user-invocable: true5disable-model-invocation: true6allowed-tools: Read, Write, Edit, Bash, Grep, Glob, Agent, WebSearch, WebFetch7kernel:8 kind: workflow9 version: 110 side_effects: writes_meta11 confirmation: on_side_effect12---1314<skill id="experiment">1516<purpose>17Rules without evidence are superstitions. One invocation, no subcommands: the engine18figures out what the hypothesis system needs — seeds, tests, graduates, or kills.1920 - No hypotheses? Seeds them from CLAUDE.md.21 - Hypotheses exist? Picks the most uncertain, designs an experiment, runs it.22 - Evidence accumulating? Graduates proven rules, kills disproven ones.23 - Everything tested? Reports and stops.2425Rules that survive become convictions. Rules that fail become learnings.26</purpose>2728<reference>29Deep patterns, SQL schema, domain design templates, confidence-scoring examples:30skills/experiment/reference/experiment-research.md31</reference>3233<skill_load>34always: skills/quality/SKILL.md, skills/build/reference/testing.md35</skill_load>3637<on_start>38```bash39agentdb read-start40agentdb emit command "experiment-start" "" '{}'41```42</on_start>4344<cycle id="experiment" max_iterations="20">4546 <phase id="sense" name="SENSE — Read the State">47 Autonomous entry point. Determine what the system needs.4849 ```bash50 agentdb hypothesis list 2>/dev/null51 ```5253 Decision tree (no human input needed):54 1. No hypotheses table or empty? → go to SEED phase.55 2. Hypotheses exist but all are unproven? → go to PICK phase.56 3. Mix of tested/untested? → go to PICK phase (prioritize untested).57 4. All have >= 3 experiments? → go to JUDGE phase.58 5. Graduation/kill candidates exist? → go to EVOLVE phase.59 </phase>6061 <phase id="seed" name="SEED — Extract Rules as Hypotheses" trigger="sense.no_hypotheses">62 Scan every CLAUDE.md in the project hierarchy + rules/*.md + skills/*/SKILL.md.6364 Parse rule-like patterns:65 - Imperative: "Always X", "Never Y", "Prefer Z", "Must W"66 - Anti-patterns: block actions, "Don't", "Forbidden"67 - Assertions: "X before Y", "X is better than Y"68 - Quantitative claims: "reduces by X%", "takes N minutes"69 - Conditional: "If X then Y", "When X, do Y"7071 For each rule:72 ```bash73 agentdb hypothesis add "<statement>" --domain <auto-classify> --source "<file:line>"74 ```7576 Domain auto-classification by keyword:77 - research, anti-pattern, prior work → methodology78 - parallel, agent, spawn, tier → coordination79 - test, coverage, edge case, mock → testing80 - commit, branch, merge, PR → git81 - secret, validation, auth, injection → security82 - measure, optimize, latency, profile → performance83 - Big 5, review, quality → quality84 - module, interface, coupling → architecture8586 Deduplicate: skip if near-identical statement already exists.87 Log count, then immediately proceed to PICK. No pause.8889 ```bash90 agentdb emit command "experiment-seed" "" '{"seeded":N}'91 ```92 </phase>9394 <phase id="pick" name="PICK — Select Next Hypothesis">95 Choose the hypothesis that will produce the most information.9697 Priority order:98 1. **Most uncertain**: confidence closest to 0.5 (maximum ignorance — any experiment is maximally informative)99 2. **Least tested**: fewest total experiments (break ties)100 3. **Highest impact domain**: methodology > coordination > security > testing > quality > git > architecture > performance101102 ```sql103 SELECT id, statement, domain, confidence, evidence_for + evidence_against as total_evidence104 FROM hypotheses105 WHERE status NOT IN ('graduated', 'refuted')106 ORDER BY ABS(confidence - 0.5) ASC, total_evidence ASC107 LIMIT 1;108 ```109 </phase>110111 <phase id="design" name="DESIGN — Create the Experiment">112 Autonomously design the minimum viable experiment.113114 **Falsifiability gate: if no possible outcome could refute the hypothesis, redesign.**115 Every experiment defines BEFORE running: method, quantitative measurement, control116 condition (what happens WITHOUT the rule), pass_criteria, fail_criteria.117118 Choose the LIGHTEST experiment type that produces signal:119120 1. **HISTORICAL** (cheapest — query existing data):121 Query agentdb learnings, session outcomes, error patterns for evidence.122 Use when: agentdb has >= 10 sessions or >= 20 learnings in the domain.123 2. **COMPARATIVE** (medium — run a real task two ways):124 Execute WITH the rule applied, then WITHOUT (or find prior without-cases).125 Measure: time, error count, rework, quality.126 3. **ABLATION** (medium — remove the rule, observe):127 Temporarily ignore the rule during a real task. Record what breaks.128 4. **OBSERVATIONAL** (passive — tag next N tasks):129 Flag the hypothesis; future relevant tasks collect evidence passively.130 Use when: active experimentation would be disruptive.131132 Minimum sample sizes: methodology/coordination/git/quality >= 3 comparisons;133 testing >= 5 tasks per condition; security >= 50 fuzz inputs.134135 ```bash136 agentdb experiment add <H_ID> "<method>" "<measurement>" --pass-criteria "<criteria>"137 ```138 </phase>139140 <phase id="run" name="RUN — Execute and Observe">141 Run the designed experiment. Record everything.142143 **Gate: the control condition was actually tested, not just assumed.**144145 - HISTORICAL: query agentdb with specific SQL; evidence = query result + interpretation.146 - COMPARATIVE: execute the task (spawn agents if needed); evidence = measured delta.147 - ABLATION: execute with the rule explicitly ignored; evidence = observed difference.148 - OBSERVATIONAL: record the flag; skip to next hypothesis (no blocking).149 </phase>150151 <phase id="conclude" name="CONCLUDE — Verdict and Confidence Update">152 Compare observations against pass/fail criteria. Issue verdict honestly:153 **supports** | **refutes** | **inconclusive**.154155 ```bash156 agentdb experiment verdict <EXP_ID> <supports|refutes|inconclusive> "<evidence summary>"157 ```158159 Confidence update (Bayesian, applied automatically by CLI):160 - supports: confidence += (1 - confidence) * 0.25161 - refutes: confidence -= confidence * 0.3162 - inconclusive: no change163164 Evidence strings must be specific and measurable, never narrative.165166 Lifecycle transitions:167 - unproven → testing: first experiment registered168 - testing → supported: confidence >= 0.8 AND evidence_for >= 3 AND ratio >= 3:1169 - testing → refuted: confidence < 0.2 AND evidence_against >= 2170 - supported → graduated: human approval after sustained confidence171 - refuted → killed: human approval to remove from rules172 - any → unproven: rule is modified (resets all evidence)173174 ```bash175 agentdb learn pattern|failure "<what we learned>" "<evidence>"176 agentdb emit command "experiment-conclude" "" '{"H":"ID","EXP":"ID","verdict":"X","confidence":0.XX}'177 ```178179 Loop back to PICK for next hypothesis.180 </phase>181182 <phase id="judge" name="JUDGE — Review All Evidence" trigger="sense.sufficient_evidence">183 For each hypothesis with >= 3 experiments: summarize evidence, calculate final184 confidence, classify graduated | refuted | needs-more-evidence | inconclusive.185186 ```bash187 agentdb hypothesis export188 ```189 Write detailed report to _meta/research/experiment-report.md. Proceed to EVOLVE.190 </phase>191192 <phase id="evolve" name="EVOLVE — Self-Reconfigure">193 The emergent part. The system reconfigures based on evidence.194195 **Graduate** (confidence >= 0.8, evidence_for >= 3, ratio >= 3:1):196 promote via the artifact ladder with human approval — hook if enforceable, agent if197 a role, skill if methodology; CLAUDE.md prose only as last resort.198199 **Kill** (confidence < 0.2, evidence_against >= 2):200 propose rule removal from CLAUDE.md (present to human).201202 **Mutate** (inconclusive after 5+ experiments):203 the hypothesis may be poorly stated; propose a refined version as a NEW hypothesis,204 linked to the original (evolution chain).205206 <ask_user>207 Use AskUserQuestion ONCE at the end of the evolve phase:208 Ask: "{graduated} rules proven, {killed} rules disproven, {mutated} rules refined. Apply changes?"209 Options: apply all, review individually, skip for now210 </ask_user>211212 ```bash213 agentdb emit command "experiment-evolve" "" '{"graduated":N,"killed":N,"mutated":N}'214 ```215 </phase>216217</cycle>218219<loop_control>220 continue_if: untested hypotheses remain OR new evidence changes confidence significantly221 pause_at: EVOLVE phase (only human checkpoint — graduation/kill decisions)222 stop_if: all hypotheses have >= 3 experiments AND no graduation/kill candidates223 on_stop: write final report to _meta/research/experiment-report.md, agentdb write-end224 Iteration budget: max 20 cycles per invocation.225</loop_control>226227<anti_patterns>228 <never>Confirm a hypothesis without running a real experiment.</never>229 <never>Use a single data point to graduate a hypothesis.</never>230 <never>Ignore refuting evidence because the rule "feels right".</never>231 <never>Test a hypothesis with a method that can only confirm (design for falsifiability).</never>232 <never>Modify the hypothesis after seeing results (that is a new hypothesis).</never>233</anti_patterns>234235<hard_stops>236 - NEVER modify CLAUDE.md autonomously. Present changes at EVOLVE, human decides.237 - NEVER delete hypotheses. Mark as refuted. Audit trail is sacred.238 - NEVER fabricate evidence. If experiment can't run, mark inconclusive with reason.239 - NEVER run destructive experiments without explicit approval.240 - ALWAYS record evidence, even for inconclusive results.241</hard_stops>242243<on_end>244```bash245agentdb write-end '{"skill":"experiment","cycles":N,"experiments_run":N,"graduated":N,"refuted":N,"mutated":N}'246```247</on_end>248249</skill>