/spark-to-paper:ts-paper-experimentfrom spark-to-paper
Repairs AI-generated scientific paper drafts by diagnosing research logic, running feasible experiments, rewriting the experiment section, and ensuring claim-evidence consistency in LaTeX manuscripts.
Ships in spark-to-paper. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Now part of the spark-to-paper-skills suite (Stage 8). Previously a separate project (AutoPaperFactory); merged in so the whole pipeline lives in one repo. It runs in an experiment workspace (default
<ts_paper_run>/experiments/, seeded byts-paper/scripts/handoff_to_experiments.pywith this skill'spaper_config.yamltemplate). "Project root" below = that workspace. Overleaf is OFF by default; enable via the workspace.env(OVERLEAF_GIT_URL/OVERLEAF_TOKEN) — also in repo-root.env.example. References to "AutoPaperFactory" in the resource docs mean this same workspace.
Repair an AI-generated scientific paper draft into a more complete, honest manuscript. This
skill diagnoses the paper, plans and runs only feasible experiments, edits the LaTeX
manuscript directly inside ./paper/, and keeps the full paper claim–evidence consistent.
Assume Claude Code is always started from the project root (the directory that contains
./paper_config.yaml). The project root is .. Use relative paths only — never absolute or
machine-specific paths. Key locations:
./paper_config.yaml — project configuration./draft_overleaf.zip — the AI-generated Overleaf export (primary input)./input/draft/ — alternative location for raw draft files./paper/ — the manuscript: the source of truth, an independent Git repo synced to Overleaf./workspace/ — diagnosis, experiment planning/runs, logs, lessons (never the manuscript)./outputs/ — reports, analysis, exported figures/tables (never the source-of-truth manuscript)./paper/ is the source of truth for the manuscript.
All LaTeX manuscript edits must happen directly inside ./paper/.
Allowed manuscript files in ./paper/ include:
.tex.bib.sty.clsDo not put the following inside ./paper/:
AUTHOR_TODO)../paper/ is the manuscript source of truth. Do not create a competing "final"
manuscript under ./outputs/final/, and do not copy any file from ./outputs/ back into
./paper/. Edit the manuscript in place inside ./paper/../paper/ (GR-022).
A Monte Carlo may live in ./workspace/ to sanity-check an estimator, but its numbers never enter the
manuscript and the manuscript never calls anything a "simulation".-- result table after a run is a failure; report null/insignificant results honestly (with SE and p),
but the manuscript's own tables must carry the values../paper/'s Overleaf remote at the end (GR-026); re-run the Step 8–17
consistency/review on the FINAL manuscript whenever results/tables/abstract/conclusion change (GR-027).resources/golden_rules.md and resources/claim_evidence_rules.md for the full policy.Embedded (ts-paper Stage 8) mode — the DEFAULT in this suite, and it AUTO-RUNS. When driven by the
ts-paper orchestrator, the draft is ALREADY staged under ./input/draft/ as a LaTeX manuscript
(main.tex + sections/ + refs.bib + figures/ + template .sty — NOT a zip), real experiment
inputs (if present) are under ./input/{data,code}, and overleaf.require_overleaf_url is false.
In this mode auto-proceed without stopping: ingest ./input/draft/ into ./paper/ and run the full
workflow end-to-end — do NOT ask for a zip or an Overleaf URL. (The "stop and ask" prompts below apply
ONLY to standalone manual usage, never to embedded Stage-8 runs.)
./input/draft/ (the staged manuscript — primary in the
embedded workflow), ./draft_overleaf.zip (standalone only), or existing LaTeX files under ./paper/.overleaf.require_overleaf_url from ./paper_config.yaml.
false (Overleaf disabled): skip the Overleaf Git target check, the URL ask, and all
pushing entirely. Work only on the local ./paper/ repo (init + local commits, no remote, no
push), regardless of the push_* flags. Do not call init_paper_overleaf.py --push. Then continue
to the draft check below.true: enforce the Overleaf Git target as described next.overleaf.git_url in
./paper_config.yaml, or OVERLEAF_GIT_URL in ./.env, or an existing remote named
overleaf inside ./paper/. (paper_config.yaml takes precedence, then the .env value.)If the AI draft is missing (standalone manual usage only — in embedded Stage-8 mode ./input/draft/
is always present, so never reached), stop and ask:
Please provide the AI draft. Put an Overleaf project zip at ./draft_overleaf.zip, or place the draft files under ./input/draft/.
If require_overleaf_url is true and the Overleaf Git URL is missing, stop and ask:
Please provide the Overleaf Git URL. Create a blank Overleaf project first, open Git Integration, and paste the Git URL into ./paper_config.yaml under overleaf.git_url.
Security rule: Do not ask for passwords or tokens in the prompt. For non-interactive pushes,
the user can create a ./.env file with OVERLEAF_GIT_URL and OVERLEAF_TOKEN. The token is
read only from ./.env, is never stored in paper_config.yaml, never written into the
git remote URL, and never printed. scripts/init_paper_overleaf.py supplies it to git via a
temporary askpass helper. ./.env is gitignored and must never be committed. A Git credential
helper or SSH also works.
Then:
./paper/ (unzip ./draft_overleaf.zip and/or copy
./input/draft/ files into ./paper/)../paper/ as an independent Git repository../paper/ with message: Initial import of AI draft.overleaf.push_initial_draft).You may use the helper scripts/init_paper_overleaf.py (add --push to push). Never run git in
the parent AutoPaperFactory repository for paper content.
./paper/ (the .tex/.bib sources).paper_config.yaml and the resources: methodology_core.md, golden_rules.md,
anti_patterns.md, experiment_templates.md, claim_evidence_rules.md,
contribution_type_rules.md, human_scientific_style.md, sci_q4_review_checklist.md,
reference_verification.md, experiment_table_audit.md, publication_polish_check.md,
final_submission_checklist.md, post_repair_narrative_review.md, dataset_license_gate.md,
code_experiment_paper_consistency.md, raw_result_recomputation.md,
rendered_pdf_layout_check.md, reproducible_artifact_packaging.md,
experiment_prerun_approval_gate.md../workspace/diagnosis/:
DIAGNOSIS.md, PAPER_LOGIC_MAP.md, EXPERIMENT_GAP_REPORT.md../workspace/experiments/EXPERIMENT_PLAN.md specifying:
which experiments are necessary, which are feasible with available data/code, which are
blocked (and why), metrics, baselines, expected outputs, and commands/
scripts to run. Use resources/experiment_templates.md. Plan the minimum set../outputs/reports/PRERUN_PLAN_APPROVAL.md covering, per experiment: estimated runtime,
disk, compute/cost, external data needed (with the Dataset / License / Terms Gate,
Step 3), and whether it is needed for an essential claim. Cheap, local, already-available
runs may proceed without a separate approval; costly/external ones must wait for approval. See
resources/experiment_prerun_approval_gate.md../input/code/, run existing scripts or create minimal
scripts only when necessary, and use the seeds in paper_config.yaml.resources/dataset_license_gate.md): dataset name; source URL; expected download
size; license / terms-of-use status; whether user confirmation is required; disk
requirement; estimated runtime; and whether the dataset is needed for essential claims.
If the license/ToU is unclear, stop and ask the user../workspace/experiments/ and ./outputs/ (final
tables/figures to ./outputs/tables/ and ./outputs/figures/)../paper/.workspace/experiments/EXPERIMENT_RUN_REPORT.md. If
experiments cannot be run, create workspace/experiments/EXPERIMENT_REQUIREMENTS.md instead../outputs/reports/RESULT_ANALYSIS.md: main findings; whether
each original claim is supported (labels from resources/claim_evidence_rules.md); weak or
negative results (do not hide them); limitations; which claims must be weakened or removed.Before any reported number is written into the manuscript, verify that the evidence is real and
that the code matches the paper. This gate reads the current paper project's evidence
(./input/code/, ./workspace/experiments/, ./outputs/) — it does not invent or run anything
new here. See resources/code_experiment_paper_consistency.md. Produce six reports under
./outputs/reports/:
RESULT_PROVENANCE_AUDIT.md — every numeric value in tables/figures must trace to:
dataset, model/variant, seed, metric, source JSON/CSV/log path, and
aggregation script. No value may be guessed, manually invented, or written from memory.
Recompute each reported value from the per-seed raw logs and confirm it matches (GR-019);
record mismatches. See resources/raw_result_recomputation.md; the helper
scripts/check_result_recomputation.py aggregates per-seed logs to assist this check.EXPERIMENT_COMPLETENESS_AUDIT.md — for every reported table/figure, verify all reported
model × dataset × seed × metric combinations were actually run. Classify each combination as
FULLY_RUN, PARTIALLY_RUN, NOT_RUN_BUT_NOT_CLAIMED, or CLAIMED_BUT_NOT_RUN.CODE_PAPER_CONSISTENCY_AUDIT.md — verify the code implements what the paper describes
(components, corruption protocol, all baselines, all ablations, all metrics). If the paper
describes a component the code does not implement, stop and report. The helper
scripts/check_code_paper_consistency.py scans ./input/code/ for expected artifact types to
assist this check.EXPERIMENT_DESIGN_CORRECTNESS_AUDIT.md — check for train/test leakage, correct split
protocol, seeds actually used, task-appropriate metrics, truly-not-applicable N/A cells,
offset MAE only where offset labels exist, retrieval metrics only for models with alignment
scores, and that cross-dataset replication is not falsely described as zero-shot transfer.CODE_ARTIFACT_COMPLETENESS_AUDIT.md — check that preprocessing, feature extraction, model
definitions, baseline definitions, training script, evaluation script, table/figure generation
script, and config/documented commands are preserved. If code only exists as scratch scripts,
report a reproducibility risk. Use resources/reproducible_artifact_packaging.md for the
target packaging layout.EXPERIMENT_TRUTHFULNESS_VERDICT.md — a single overall verdict, one of:
FULLY_TRACEABLE_AND_CONSISTENT, TRACEABLE_WITH_MINOR_GAPS, PARTIAL_TRACEABILITY_RISK,
CODE_PAPER_MISMATCH, or UNVERIFIED_RESULTS_RISK.Enforcement: never write a number that fails provenance. If anything is CLAIMED_BUT_NOT_RUN,
or the verdict is CODE_PAPER_MISMATCH / UNVERIFIED_RESULTS_RISK, weaken or remove the affected
claim, or stop and ask the user — do not fabricate (GR-018).
.tex files directly inside ./paper/ to rewrite the experiment section:
setup, dataset, baselines, metrics, implementation details, main results, and any available
ablation/sensitivity/efficiency/qualitative analysis, plus limitations.resources/result_writing_patterns.md. Results describe observations;
interpretation belongs in the discussion (GR-007). Every table/figure must be traceable to a
log/CSV/author file.resources/contribution_type_rules.md:
framework / model / algorithm / benchmark / dataset / system / empirical study / application
paper. Do not assume the Proposed row in a results table is the whole contribution (GR-013)../outputs/reports/CLAIM_TYPE_CLASSIFICATION.md and use it to keep the next step's
claim-evidence checking aligned with the actual contribution (not just one table row)../paper/ so the whole paper is claim–evidence consistent.AUTHOR_TODO unsupported claims../outputs/reports/CLAIM_EVIDENCE_CHECK.md recording each claim's type (Step 7),
label, evidence artifact, and action.resources/human_scientific_style.md directly to the manuscript files in ./paper/:
one sentence one idea, short sentences, remove AI filler and empty adjectives, no grandiose
claims, every paragraph starts with a clear point, claim strength matches evidence. Do not
attempt to bypass AI detection — focus on clarity, accuracy, and scientific style.Per resources/experiment_table_audit.md, write
./outputs/reports/EXPERIMENT_TABLE_NECESSITY_AUDIT.md:
./paper/.Per resources/publication_polish_check.md, write
./outputs/reports/PUBLICATION_POLISH_CHECK.md checking:
-- definitions, and whether missing cells are truly not applicable;Fixes are applied by editing the manuscript in ./paper/ (never change values without a
traceability reason).
Run after manuscript repair and before the final submission checks. Per
resources/reference_verification.md, write
./outputs/reports/REFERENCE_VERIFICATION_REPORT.md:
resources/sci_q4_review_checklist.md and write the review report to
./outputs/reports/SCI_Q4_READINESS.md (per-item pass/fail + a readiness score)../paper/.scripts/consistency_check.py to scan the ./paper/ .tex files for risky terms.Successful LaTeX compilation is not sufficient (GR-020). Compile the manuscript in ./paper/
and visually check the rendered PDF pages. Write ./outputs/reports/PDF_LAYOUT_CHECK.md (see
resources/rendered_pdf_layout_check.md). Check for:
?? references, citations, or undefined labels in the rendered output;The helper scripts/check_pdf_layout.py locates the compiled PDF under ./paper/ and reports page
count / render hints (using pdfinfo/pdftoppm if available). Apply fixes by editing ./paper/.
Do not commit the rendered PDF or page images to the AutoPaperFactory repo.
Per resources/final_submission_checklist.md, write
./outputs/reports/FINAL_SUBMISSION_CHECKLIST.md checking:
AUTHOR_TODO in the manuscript;If any item fails, fix it in ./paper/ (or flag it to the user) before the final commit/push.
git status inside ./paper/../paper/ with a clear message:
Repair manuscript after experiment and consistency review.overleaf.push_after_repair).This is the final mandatory step, run after manuscript repair, the consistency check, the
commit, and the Overleaf push. It compares the repaired manuscript against the original imported
AI draft and judges whether the paper is overall better or worse. See
resources/post_repair_narrative_review.md.
Determine the two versions from git history inside ./paper/:
./paper/ (the Initial import of AI draft). Find it
with git -C paper rev-list --max-parents=0 HEAD.HEAD of ./paper/.git -C paper diff <initial>..HEAD (and --stat for an overview).Base every statement in both reports on the actual diff and on the evidence in
workspace/experiments/ and outputs/reports/. Do not fabricate improvements; do not
hide negative findings.
outputs/reports/ORIGINAL_TO_REPAIRED_CHANGELOG.mdCompare the repaired manuscript against the original imported AI draft. The report must answer:
workspace/experiments/ or outputs/)?outputs/reports/FINAL_NARRATIVE_INTEGRITY_REVIEW.mdJudge whether the final paper is overall better or worse than the original draft. The report must answer:
Final verdict — use exactly one of these labels:
SIGNIFICANTLY_IMPROVEDIMPROVED_BUT_WEAKER_CLAIMSHONEST_BUT_STILL_WEAKNARRATIVE_DAMAGEDNOT_READYJudgment rules:
NARRATIVE_DAMAGED).workspace/lessons/LESSONS_LEARNED.md: what worked, what failed, repeated AI-draft
problems, useful user decisions, candidate golden rules..claude/skills/ts-paper-experiment/memory/lessons_candidate.md.resources/golden_rules.md; promotion needs explicit
user approval and is recorded in memory/rule_change_log.md.During every paper repair task, Claude Code must actively watch for improvement opportunities.
It should capture suggestions in these categories:
Writing rules
Experiment rules
Workflow rules
Safety and integrity rules
Skill improvement rules
Claude Code must create or update ./workspace/lessons/SUGGESTIONS_FOR_USER.md using this
format (one block per suggestion, numbered SUG-001, SUG-002, ...):
# Suggestions for User Review
## Suggestion SUG-001
Category:
writing / experiment / workflow / safety / skill
Observation:
What happened in this paper?
Trigger:
When should this suggestion apply?
Suggested rule or change:
What should be added or changed?
Recommended action:
accept / reject / revise / observe more
Scope:
general / ML papers / image papers / NLP papers / this paper only
Automation level:
manual / ask-user / auto
Risk:
low / medium / high
Reason:
Why this suggestion matters
User decision:
PENDING
./.claude/skills/ts-paper-experiment/memory/lessons_candidate.md (use the candidate format in
that file).resources/golden_rules.mdresources/human_scientific_style.mdresources/experiment_templates.mdresources/sci_q4_review_checklist.mdmemory/rule_change_log.md).At the end of each paper repair task, Claude Code must print a short message:
I found N suggestions for improving the workflow/rules. Please review ./workspace/lessons/SUGGESTIONS_FOR_USER.md and tell me which ones to promote.
(Replace N with the actual number of suggestions captured.)
./paper/ initialized; original AI draft committed (Initial import of AI draft) and pushedworkspace/diagnosis/DIAGNOSIS.md, PAPER_LOGIC_MAP.md, EXPERIMENT_GAP_REPORT.mdworkspace/experiments/EXPERIMENT_PLAN.mdoutputs/reports/PRERUN_PLAN_APPROVAL.md (for expensive/external-data experiments; user-approved)EXPERIMENT_RUN_REPORT.md or EXPERIMENT_REQUIREMENTS.mdoutputs/reports/RESULT_ANALYSIS.mdoutputs/reports/RESULT_PROVENANCE_AUDIT.mdoutputs/reports/EXPERIMENT_COMPLETENESS_AUDIT.mdoutputs/reports/CODE_PAPER_CONSISTENCY_AUDIT.mdoutputs/reports/EXPERIMENT_DESIGN_CORRECTNESS_AUDIT.mdoutputs/reports/CODE_ARTIFACT_COMPLETENESS_AUDIT.mdoutputs/reports/EXPERIMENT_TRUTHFULNESS_VERDICT.md (with one verdict label)outputs/reports/CLAIM_TYPE_CLASSIFICATION.md (contribution type + per-claim types).tex edits made directly in ./paper/ (experiment section + full-paper consistency + style)outputs/reports/CLAIM_EVIDENCE_CHECK.mdoutputs/reports/EXPERIMENT_TABLE_NECESSITY_AUDIT.mdoutputs/reports/PUBLICATION_POLISH_CHECK.mdoutputs/reports/REFERENCE_VERIFICATION_REPORT.md (verification source stated per entry)outputs/reports/SCI_Q4_READINESS.mdoutputs/reports/PDF_LAYOUT_CHECK.md (rendered PDF visually checked)outputs/reports/FINAL_SUBMISSION_CHECKLIST.md./paper/ repaired manuscript committed (Repair manuscript after experiment and consistency review) and pushedoutputs/reports/ORIGINAL_TO_REPAIRED_CHANGELOG.md (original initial-commit vs repaired HEAD)outputs/reports/FINAL_NARRATIVE_INTEGRITY_REVIEW.md (with one verdict label)workspace/lessons/LESSONS_LEARNED.md + appended candidate rulesworkspace/lessons/SUGGESTIONS_FOR_USER.md written + closing message printedmemory/failed_cases.md (opens in a new tab)memory/lessons_candidate.md (opens in a new tab)memory/lessons_validated.md (opens in a new tab)memory/rule_change_log.md (opens in a new tab)paper_config.yaml (opens in a new tab)resources/anti_patterns.md (opens in a new tab)resources/claim_evidence_rules.md (opens in a new tab)resources/code_experiment_paper_consistency.md (opens in a new tab)resources/contribution_type_rules.md (opens in a new tab)resources/dataset_license_gate.md (opens in a new tab)resources/experiment_prerun_approval_gate.md (opens in a new tab)resources/experiment_table_audit.md (opens in a new tab)resources/experiment_templates.md (opens in a new tab)resources/final_submission_checklist.md (opens in a new tab)resources/golden_rules.md (opens in a new tab)resources/human_scientific_style.md (opens in a new tab)resources/methodology_core.md (opens in a new tab)resources/post_repair_narrative_review.md (opens in a new tab)resources/publication_polish_check.md (opens in a new tab)resources/raw_result_recomputation.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (spark-to-paper-skills/spark-to-paper-skills) — no native marketplace selected
npx claudepluginhub p/spark-to-paper-skills-spark-to-paper14 skills in this plugin
/ts-figure-optimizeThe suite's SOLE figure vectorizer: turn ONE raster scientific figure (a PNG/JPG, e.g. a gpt-image-2 schematic) into an editable, publication-ready figure via DrawAI's **key-free HYBRID** — local perception (SAM3 region detection + PaddleOCR + Box-IR layout, no account) then a deterministic hybrid build that keeps the approved render **pixel-exact** (a whole-canvas raster) and lays an **editable <text> overlay** on top (~0.91 SSIM), exported as a self-contained SVG + vector PDF + an editable PPTX. The render's full richness is preserved EXACTLY (it IS the approved image) while every label becomes editable. The original raster is always kept. Hybrid is the ONLY mode used: there is no Codex full-vector redraw (legacy/off — it needs an account, and a redraw of a dense figure loses fidelity) and no Claude-redraw fallback. If this runtime cannot be provisioned, the caller keeps the approved PNG as-is — never a lossy redraw. Independent of the paper pipeline — give it any figure image.
/ts-figure-svgPaperBanana+ — turn a paper's figure brief into a native, editable, publication-grade SVG. Stage 1 runs the OFFICIAL PaperBanana (dwzhu-pku/PaperBanana, pulled by `setup_paperbanana.py`, its own Retriever→Planner→Stylist→Visualizer→Critic pipeline) to produce candidate PNGs. Stage 2 is the "+": Claude LOOKS at the chosen PNG, extracts its DESIGN LANGUAGE (palette, type scale, spacing, idiom) into a style sheet, then redraws the figure FROM THE PAPER'S FACTS as real <rect>/<path>/<text> objects — never tracing pixels, never embedding the PNG. Stage 3 is a measured repair loop: `audit_svg.py` (stdlib, no renderer needed) catches overflow, text-on-text, icons cutting labels, stroke-scaled and canvas-clipped arrowheads, dangling connectors, sub-legible type, font-fallback glyphs, CSS-cascade colour traps and traced path-soup; ≥4 rounds, no upper bound while defects remain. Ends on a vector PDF verified on the real compiled page. Use when a figure must be editable and correct, not merely pretty.
Other plugins' skills for the same job