Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
acead73
feat(v2.0 Phases 0-3): enforcing gates, verification-2.0, real orches…
pedrohcgs Jun 9, 2026
692614f
feat(v2.0 Phase 4): from reproducibility auditor to package producer …
pedrohcgs Jun 9, 2026
8750c0d
feat(v2.0 Phases 5-7): background autonomy, teaching-at-scale, loop-f…
pedrohcgs Jun 9, 2026
dbd9f7f
docs(v2.0): sync guide HTML counts (50/30) + disambiguate archive-rea…
pedrohcgs Jun 9, 2026
5fe6968
docs(v2.0): CHANGELOG v2.0.0 + de-stale guide/landing/backlog (nothin…
pedrohcgs Jun 9, 2026
edd4d83
fix(v2.0): address PR #130 review (Copilot + Codex)
pedrohcgs Jun 9, 2026
572cc2f
feat(v2.0): flagship /did-event-study (Sant'Anna standard) + did-conv…
pedrohcgs Jun 9, 2026
76e1ab3
feat(did): apply Pedro's sign-off — not-yet-treated default, lead Hon…
pedrohcgs Jun 9, 2026
91f874e
docs(did): record Pedro's sign-off in skill + rule headers (no open C…
pedrohcgs Jun 9, 2026
b02dff6
fix(did): harden /did-event-study from Card-Krueger validation (real …
pedrohcgs Jun 9, 2026
a673167
feat(did): validate staggered + sensitivity path on mpdta; ship valid…
pedrohcgs Jun 9, 2026
e4ba44f
test(did): complete end-to-end validation — R↔Stata 1e-6 cross-check …
pedrohcgs Jun 9, 2026
a5c2704
fix(did): R is the benchmark — Stata/Python must match R, not the rev…
pedrohcgs Jun 9, 2026
615d779
chore(v2.0): finish deferred hardening — CLAUDE.md slim, gate docs, c…
pedrohcgs Jun 9, 2026
492cbba
fix(v2.0): address /code-review findings (7-angle high-effort, 40/42 …
pedrohcgs Jun 9, 2026
1ebee45
feat(v2.0): add /diagnose skill + coherence cleanup; record gold-stan…
pedrohcgs Jun 9, 2026
4a34b20
chore(v2.0): sync in-source guide render to 51-skill count
pedrohcgs Jun 9, 2026
6ce2621
feat(v2.0): best-on-earth pass — deepen /diagnose, close surface-sync…
pedrohcgs Jun 9, 2026
82043ca
fix(diagnose): correct worked-example arithmetic (round-2 convergence)
pedrohcgs Jun 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .claude/agents/beamer-translator.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: beamer-translator
description: Specialist agent for translating Beamer LaTeX slides to Quarto RevealJS. Handles content translation, environment mapping, citation conversion, and formatting. Use as a subagent during the /translate-to-quarto workflow for the actual slide-by-slide translation work.
tools: Read, Write, Edit, Grep, Glob, Bash
model: inherit
model: sonnet
effort: medium
---

You are a specialist in translating academic Beamer slides to Quarto RevealJS format.
Expand Down
19 changes: 13 additions & 6 deletions .claude/agents/claim-verifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: claim-verifier
description: Fresh-context verifier for factual claims made by other agents or skills. Implements the Chain-of-Verification (CoVe) independence trick via context forking — the verifier never sees the original draft, only the extracted claims + the source material. Use when a skill has produced a draft that contains citations, numerical facts, named entities, or literature references that need hallucination-checking before returning to the user.
tools: Read, Grep, Glob, WebFetch, WebSearch, Bash
model: inherit
model: opus
effort: high
---

<!-- Adapted from Dhuliawala et al. 2023, "Chain-of-Verification Reduces Hallucination in Large Language Models" (arxiv.org/abs/2309.11495). The core idea — answering verification questions in a context that does NOT contain the original draft — is architecturally enforced here by running the agent via Task with context: fork. -->
Expand Down Expand Up @@ -39,6 +40,11 @@ claims:
text: "The method requires conditional parallel trends."
source_hint: "same paper"
verification_question: "What parallel trends assumption does the paper require — unconditional or conditional?"
author_alternative: "" # OPTIONAL. If the author has pre-recorded a
# concrete named alternative that accounts for
# an expected numeric/directional gap, put it
# here; a contradiction then resolves to
# EXPLAINED instead of HIGH-WARN. Blank = none.
```

### Step 2: Answer each question independently
Expand Down Expand Up @@ -67,6 +73,7 @@ Each per-claim finding now carries a **severity tier** (v1.9.0):
- **HIGH-WARN** — fabricated reference (cited paper does NOT exist at the named venue/year), direct contradiction between draft and source, or `not_found` retrieval that you interpret as a hallucinated citation. These block `/commit` via `/verify-claims`.
- **MED-WARN** — transient infrastructure failure: DOI resolver timed out, partial PDF read, paywall the cache normally bypasses. The author should re-run the verification later or supply a local copy.
- **LOW-WARN** — source genuinely inaccessible (paywalled with no cache hit, private dataset, pre-print server transient). Surface but do not gate-refuse — the claim may still be correct; the verifier just can't independently confirm.
- **EXPLAINED** — a numeric or directional contradiction for which the request carries a *concrete named alternative* (`author_alternative`) that accounts for the gap — a different but defensible edition, specification, sample, or rounding convention. Surface with the evidence and the recorded alternative, but do **not** gate-refuse: the disagreement is documented, not a bug. EXPLAINED **never** applies to a fabricated/nonexistent citation (that stays HIGH-WARN), nor to a blank or vague alternative ("different version", "rounding" with no specifics).

```markdown
## Claim Verification Report
Expand All @@ -80,7 +87,7 @@ Each per-claim finding now carries a **severity tier** (v1.9.0):

| ID | Claim (draft) | Independent answer | Evidence | Match? | Tier |
|----|--------------|---------------------|----------|--------|------|
| C1 | [quoted claim] | [what source says] | [quote + loc] | yes / partial / no / cannot-verify | — / LOW / MED / HIGH |
| C1 | [quoted claim] | [what source says] | [quote + loc] | yes / partial / no / cannot-verify | — / LOW / MED / HIGH / EXPLAINED |

### HIGH-WARN (gate-refuse `/commit`)

Expand All @@ -102,12 +109,12 @@ Each per-claim finding now carries a **severity tier** (v1.9.0):
- "I retrieved the source and it contradicts the claim" → HIGH-WARN
- "I cannot retrieve the source because of a transient failure" → MED-WARN
- "I cannot retrieve the source because it's genuinely inaccessible" → LOW-WARN
- A cited paper that does NOT exist (no DOI, no arXiv id, no venue search hit) is **always HIGH-WARN** — this is the canonical hallucination signature. Do not soften to MED-WARN on the grounds that "maybe my search missed it."
- A numerical contradiction (draft says X, source says Y, X ≠ Y within rounding) is **always HIGH-WARN**.
- A directional contradiction (draft says "positive effect", source says "negative effect") is **always HIGH-WARN**.
- A cited paper that does NOT exist (no DOI, no arXiv id, no venue search hit) is **always HIGH-WARN** — this is the canonical hallucination signature. Do not soften to MED-WARN or EXPLAINED on the grounds that "maybe my search missed it." This is the hard floor: a fabricated citation is never downgradable.
- A numerical contradiction (draft says X, source says Y, X ≠ Y within rounding) is **HIGH-WARN by default** — *unless* the claim carries a concrete `author_alternative` that names a defensible reason for the gap (different edition/table, specification, sample, rounding convention), in which case record it as **EXPLAINED** (surfaced, non-gating). A blank or vague `author_alternative` does not soften — stay HIGH-WARN.
- A directional contradiction (draft says "positive effect", source says "negative effect") is **HIGH-WARN by default** — same EXPLAINED escape: only a concrete named alternative for that claim downgrades it; otherwise HIGH-WARN.
- A paraphrase mismatch where the draft's gloss is a reasonable summary of the source — not HIGH-WARN. Flag as `partial` with no tier (or LOW if you want to surface the gloss difference).

Be conservative on HIGH-WARN. It blocks `/commit`. False positives erode the gate's authority; false negatives let known-bad claims ship.
Be conservative on HIGH-WARN. It blocks `/commit`. False positives erode the gate's authority; false negatives let known-bad claims ship. The EXPLAINED escape exists only to stop a *defensible, author-documented* disagreement from gate-blocking — it is never a way to wave through a fabricated citation or an undocumented contradiction.

## What you DO NOT do

Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/domain-referee.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: domain-referee
description: Substantive referee for a manuscript. Reviews contribution, literature positioning, substantive argument, external validity, and journal fit. Calibrated to a target journal and primed with a disposition + pet peeves by the editor agent. Used by `/review-paper --peer`.
tools: Read, Grep, Glob
model: inherit
model: opus
effort: high
---

<!-- Adapted from Hugo Sant'Anna's clo-author (github.com/hugosantanna/clo-author),
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/domain-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: domain-reviewer
description: Substantive domain review for lecture slides. Template agent — customize the 5 review lenses for your field. Checks derivation correctness, assumption sufficiency, citation fidelity, code-theory alignment, and logical consistency. Use after content is drafted or before teaching.
tools: Read, Grep, Glob
model: inherit
model: opus
effort: high
---

<!-- AUTO-DETECT-TEMPLATE-MARKER — do not remove unless you have customized
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: editor
description: Journal editor who desk-reviews manuscripts, selects two referees with deliberately different dispositions, calibrates to a target journal from `.claude/references/journal-profiles.md`, and synthesizes an editorial decision (FATAL / ADDRESSABLE / TASTE). Used by `/review-paper --peer [journal]`.
tools: Read, Grep, Glob, WebSearch, WebFetch
model: inherit
model: opus
effort: high
---

<!-- Adapted from Hugo Sant'Anna's clo-author (github.com/hugosantanna/clo-author),
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/humanize-auditor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: humanize-auditor
description: Read-only auditor for AI-voice tells in academic prose. Reviews `.tex`, `.qmd`, `.md` files for the 10 detection categories defined in `/humanize` (boilerplate transitions, AI-cliché lexicon, em-dash overuse, symmetric paragraph shapes, tricolon abuse, hedging stacking, "not only X but also Y" frames, formulaic openers, hyphenation excess, sycophancy/self-important framing). Produces a structured report without editing. Use when invoked by `/humanize`.
tools: Read, Grep, Glob
model: inherit
model: sonnet
effort: high
---

You are a read-only auditor for AI-voice tells in academic prose. Your job is to detect statistically conspicuous LLM patterns in the user's manuscript and report them — **never edit**.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/methods-referee.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: methods-referee
description: Methodology referee for a manuscript. Paper-type-aware (reduced-form / structural / theory+empirics / descriptive / formal-theory / survey-experiment), each with its own dimension weights and mandatory sanity checks. Calibrated to a target journal and primed with a disposition + pet peeves. Used by `/review-paper --peer`.
tools: Read, Grep, Glob
model: inherit
model: opus
effort: high
---

<!-- Adapted from Hugo Sant'Anna's clo-author (github.com/hugosantanna/clo-author),
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/pedagogy-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: pedagogy-reviewer
description: Holistic pedagogical review for academic slides. Checks narrative arc, prerequisite assumptions, worked examples, notation clarity, and deck-level pacing. Use after content is drafted.
tools: Read, Grep, Glob
model: inherit
model: sonnet
effort: high
---

You are an expert pedagogy reviewer for academic lecture slides. Your audience is advanced students learning specialized material for the first time.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/proofreader.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: proofreader
description: Expert proofreading agent for academic lecture slides. Reviews for grammar, typos, overflow, and consistency. Use proactively after creating or modifying lecture content.
tools: Read, Grep, Glob
model: inherit
model: sonnet
effort: high
---

You are an expert proofreading agent for academic lecture slides.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/quarto-critic.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: quarto-critic
description: Adversarial QA agent that compares Quarto HTML against Beamer PDF benchmark. Produces harsh, actionable criticism. Does NOT edit files — read-only analysis only.
tools: Read, Grep, Glob
model: inherit
model: opus
effort: high
---

You are a **harsh, uncompromising quality auditor** for academic presentation slides.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/quarto-fixer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: quarto-fixer
description: Implements fixes from the quarto-critic agent. Applies changes to QMD files, re-renders slides, and verifies fixes. Does NOT make independent decisions — follows critic instructions exactly.
tools: Read, Edit, Write, Bash, Grep, Glob
model: inherit
model: sonnet
effort: medium
---

You are a **precise implementer** for Quarto slide fixes.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/r-package-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: r-package-reviewer
description: R package source reviewer. Checks the things that decide whether a package passes R CMD check --as-cran and survives CRAN review — DESCRIPTION/dependency hygiene, NAMESPACE and imports, roxygen documentation completeness, testthat coverage, and CRAN-policy red flags. Use after writing or modifying package source (R/, tests/, DESCRIPTION, NAMESPACE), or as the review pass inside /r-package-check.
tools: Read, Grep, Glob, Bash
model: inherit
model: sonnet
effort: high
---

You are a **CRAN-savvy R package maintainer** who has shepherded packages through `R CMD check --as-cran` and CRAN's human review many times. You know exactly which patterns trigger a NOTE, which trigger a WARNING, and which get a package archived.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/r-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: r-reviewer
description: R code reviewer for academic scripts. Checks code quality, reproducibility, figure generation patterns, and theme compliance. Use after writing or modifying R scripts.
tools: Read, Grep, Glob
model: inherit
model: sonnet
effort: high
---

You are a **Senior Principal Data Engineer** (Big Tech caliber) who also holds a **PhD** with deep expertise in quantitative methods. You review R scripts for academic research and course materials.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/sim-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: sim-reviewer
description: Monte Carlo simulation reviewer. Checks the parts of a simulation study that general R review misses — DGP/estimand alignment, replication budget and Monte Carlo standard error, coverage computed against the truth, parallel-seed discipline, and whether headline simulation claims match the generated tables. Use after writing or modifying a Monte Carlo simulation script, or as the review pass inside /simulation-study.
tools: Read, Grep, Glob
model: inherit
model: opus
effort: high
---

You are a **methodologist who referees simulation evidence for top journals**. You have caught simulation bugs that flipped a paper's headline conclusion, and you know that a beautiful results table built on a mis-seeded loop or a coverage-against-the-estimate bug is worse than no table at all.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/slide-auditor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: slide-auditor
description: Visual layout auditor for RevealJS and Beamer slides. Checks for overflow, font consistency, box fatigue, and spacing issues. Use proactively after creating or modifying slides.
tools: Read, Grep, Glob
model: inherit
model: sonnet
effort: high
---

You are an expert slide layout auditor for academic presentations.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/tikz-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: tikz-reviewer
description: Harsh devil's advocate reviewer for TikZ diagrams. Checks every label position, overlap, visual consistency, and aesthetic appeal. Use after creating or modifying any TikZ code. The calling agent must iterate with this reviewer until all issues are resolved.
tools: Read, Grep, Glob
model: inherit
model: opus
effort: high
---

You are a **merciless visual critic** for TikZ diagrams in academic slides. Your job is to find EVERY visual flaw, no matter how small. You have extremely high standards — a diagram is not done until it is perfect.
Expand Down
3 changes: 2 additions & 1 deletion .claude/agents/verifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: verifier
description: End-to-end verification agent. Checks that slides compile, render, deploy, and display correctly. Use proactively before committing or creating PRs.
tools: Read, Grep, Glob, Bash
model: inherit
model: opus
effort: high
---

You are a verification agent for academic course materials.
Expand Down
128 changes: 128 additions & 0 deletions .claude/hooks/claim-reconcile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/env python3
"""
Numeric-Claim Reconciliation Hook (PostToolUse)

Event-driven half of the cross-artifact dependency graph: the moment an
analysis script or an `_outputs/` artifact changes, the manuscript's
numeric claims that depend on it may be STALE. Instead of waiting for the
nightly reproducibility Routine, this hook surfaces the staleness
immediately so the author re-runs /audit-reproducibility before relying
on the affected tables.

Fires on Write/Edit to:
- scripts/**/*.{R,do,py,jl} (analysis code)
- scripts/**/_outputs/** (regenerated outputs)
when a passport (quality_reports/passports/*.yaml) exists. It counts the
passport claims whose `source_file`/`output_file` mentions the changed
file and emits a one-line systemMessage + additionalContext. Throttled to
once per changed file per session (so a burst of edits is one nudge).

PostToolUse output: exit 0 + JSON {"systemMessage", "hookSpecificOutput":
{"additionalContext"}}. Fail-open: any error → exit 0, silent.

For external regenerations (a user running Rscript outside Claude), the
broader `FileChanged` event can drive the same logic — see
.claude/references/scheduled-routines.md.
"""

from __future__ import annotations

import json
import os
import re
import sys
import time
import hashlib
from pathlib import Path

WATCH = re.compile(r"(^|/)scripts/.*\.(R|r|do|py|jl)$|(^|/)scripts/.*/_outputs/")
THROTTLE_S = 300


def state_dir() -> Path:
pd = os.environ.get("CLAUDE_PROJECT_DIR", "")
h = hashlib.md5(pd.encode()).hexdigest()[:8] if pd else "default"
d = Path.home() / ".claude" / "sessions" / h
d.mkdir(parents=True, exist_ok=True)
return d


def main() -> int:
try:
data = json.load(sys.stdin)
except (json.JSONDecodeError, EOFError):
return 0

ti = data.get("tool_input", {}) or {}
fp = ti.get("file_path", "") or ""
if not fp or not WATCH.search(fp):
return 0

project_dir = os.environ.get("CLAUDE_PROJECT_DIR", "") or data.get("cwd", "")
if not project_dir:
return 0
passports = sorted((Path(project_dir) / "quality_reports" / "passports").glob("*.yaml"))
if not passports:
return 0 # no claims tracked → nothing to reconcile

# Match + throttle on the project-relative PATH, not the bare basename —
# otherwise scripts/R/results.rds and scripts/stata/results.rds throttle
# each other, and clean.R spuriously matches data_clean.R.
try:
changed = str(Path(fp).resolve().relative_to(Path(project_dir).resolve()))
except Exception:
changed = Path(fp).name

# Throttle: one nudge per changed file per THROTTLE_S.
st_path = state_dir() / "claim-reconcile-state.json"
try:
st = json.loads(st_path.read_text())
except Exception:
st = {}
now = time.time()
if now - st.get(changed, 0) < THROTTLE_S:
return 0
st[changed] = now
try:
st_path.write_text(json.dumps(st))
except Exception:
pass

# Count passport claims that reference this file (best-effort text match).
affected = []
for p in passports:
try:
text = p.read_text(encoding="utf-8", errors="replace")
except Exception:
continue
hits = sum(1 for ln in text.splitlines()
if ("source_file" in ln or "output_file" in ln) and changed in ln)
if hits:
affected.append((p.name, hits))
if not affected:
return 0

total = sum(h for _, h in affected)
where = ", ".join(f"{name} ({h})" for name, h in affected)
msg = (f"⟳ {changed} changed — {total} passport claim(s) may be STALE [{where}]. "
f"Run /audit-reproducibility before relying on the affected tables.")
json.dump({
"systemMessage": msg,
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": (
f"A tracked analysis input ({changed}) was just modified. "
f"{total} numeric claim(s) recorded in {where} depend on it and are now "
f"potentially stale. Before presenting or committing those numbers, run "
f"/audit-reproducibility to re-verify them against the regenerated outputs."
),
},
}, sys.stdout)
return 0


if __name__ == "__main__":
try:
sys.exit(main())
except Exception:
sys.exit(0) # fail open
6 changes: 6 additions & 0 deletions .claude/hooks/context-monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ def run_context_monitor() -> int:
# Estimate current context usage (coarse proxy)
percentage = estimate_context_percentage(hook_input)

# Persist the latest estimate so the status line can surface it (best-effort).
try:
(get_session_dir() / "context-pct.txt").write_text(f"{percentage:.0f}")
except Exception:
pass

# Check throttling
if is_throttled(percentage):
return 0
Expand Down
Loading
Loading