Agent skill
writer-selfloop
Writing self-loop for surveys: run the strict section-quality gate, then rewrite only the failing `sections/*.md` files until the report is PASS. **Trigger**: writer self-loop, writing loop, quality gate loop, rewrite failing sections, 自循环, 反复改到 PASS. **Use when**: per-section files exist but C5 is FAIL/BLOCKED (thin sections, missing leads/front matter, citation-scope violations, generator voice). **Skip if**: you are still pre-C2 (NO PROSE), or evidence packs are incomplete (fix C3/C4 first). **Network**: none. **Guardrail**: do not invent facts; only use citation keys present in `citations/ref.bib`; keep citations in-scope per `outline/evidence_bindings.jsonl`; do not add/remove citation keys during rewrites.
Install this agent skill to your Project
npx add-skill https://github.com/WILLOSCAR/research-units-pipeline-skills/tree/main/.codex/skills/writer-selfloop
SKILL.md
Writer Self-loop (fix only what fails)
Purpose: make writing converge without rewriting the whole paper.
This is the writing self-healing loop:
Default mode: semantic triage (LLM-first)
Treat the gate as a router, not as a reason to rewrite everything.
- First, classify each failure as: evidence substrate vs writing execution vs voice contamination vs citation hygiene.
- Then, fix the earliest responsible artifact (often not the merged draft).
- Rewrite only the failing files; do not churn working sections.
If you do not run the helper script, you can still execute this skill by reading sections/*.md + packs and writing output/WRITER_SELFLOOP_TODO.md manually in the same PASS/FAIL style.
Role cards (use explicitly)
Writing Manager (triage + convergence)
Mission: make the draft converge by fixing only failing units and routing issues upstream when needed.
Do:
- Rewrite only files flagged by the gate (one at a time).
- If evidence is thin, route upstream instead of padding prose.
- Keep citation keys and scope stable during rewrites.
Avoid:
- Global rewrites that churn working sections.
- Rewriting around evidence gaps with generic filler.
Router (earliest responsible artifact)
Mission: connect a visible writing failure to the earliest upstream fix.
Do:
- Template voice -> local rewrite (subsection-polisher / front-matter-writer / chapter-lead-writer).
- Thin evidence -> evidence-selfloop (notes/bindings/packs).
Avoid:
- Repeatedly rewriting the same section when the pack cannot support it.
Role prompt: Writing Manager (triage + convergence)
You are the writing manager for a survey draft.
Your job is to make the draft converge by fixing only what fails, and by routing issues to the earliest responsible artifact.
Rules:
- If a section fails because the evidence is thin or out-of-scope pressure is high, do NOT pad prose.
Route upstream to evidence-selfloop (notes/bindings/packs) and unblock the substrate.
- If a section fails because the prose is templated (narration openers, slide navigation, repeated disclaimer spam), rewrite locally.
- Never change citation keys during rewrites; keep scope local.
Working style:
- small, auditable edits
- one failing file at a time
- every fix either (a) improves argument moves, or (b) restores paper voice
- the gate is deterministic (it inspects
sections/+sections/sections_manifest.jsonl) - the fixes are semantic (rewrite prose to execute argument moves and restore paper voice)
Inputs
sections/sections_manifest.jsonl(expected files + allowed citations)sections/*.md(the actual prose units)outline/writer_context_packs.jsonl(preferred per-H3 pack)outline/evidence_bindings.jsonlcitations/ref.bib
Optional routing context:
output/EVIDENCE_SELFLOOP_TODO.md(if evidence gaps are already known)outline/subsection_briefs.jsonl,outline/chapter_briefs.jsonl
Output
output/WRITER_SELFLOOP_TODO.md(report-class; always written)
Workflow
- Run the gate
- Run the writer self-loop script (see Script section below). It reads
sections/sections_manifest.jsonland the actualsections/*.mdfiles.
- Read the TODO report
- Open
output/WRITER_SELFLOOP_TODO.mdand identify the failing file paths. - For each failing H3, load its pack from
outline/writer_context_packs.jsonl. - If a pack is missing or you need scope reminders, consult
outline/subsection_briefs.jsonl; for chapter-level context (leads/throughlines), consultoutline/chapter_briefs.jsonl.
- Triage (writing vs evidence)
Route upstream (run evidence-selfloop) when:
output/EVIDENCE_SELFLOOP_TODO.mdalready indicates missing anchors/comparisons for the same subsection- the pack in
outline/writer_context_packs.jsonlis too thin to satisfy argument moves without guessing - you keep wanting out-of-scope citations outside
outline/evidence_bindings.jsonl
Rewrite locally when:
- the pack is rich enough, but prose is template-y (narration openers, slide navigation, repeated discourse stems)
- the section has content but lacks a thesis, contrasts, evaluation anchoring, or limitations
- Use the right playbook for the failing file type
- Front matter (
sections/abstract.md,sections/S<sec_id>.mdfor Intro/Related Work,sections/discussion.md,sections/conclusion.md): usefront-matter-writer. - Chapter leads (
sections/S<sec_id>_lead.md): usechapter-lead-writer. - H3 bodies (
sections/S<sub_id>.md): usesubsection-writer(draft) orsubsection-polisher(local fix).
- Keep scope + citations stable
- Keep citation keys unchanged and validate them against
citations/ref.bib. - Stay in scope per
outline/evidence_bindings.jsonl(prefer subsection-first).
- Rerun the gate until PASS
After PASS (merge-aware voice safety):
- Proceed to
section-logic-polisher->argument-selfloop->paragraph-curator->style-harmonizer->opener-variator->evaluation-anchor-checker->transition-weaver->section-merger->post-merge-voice-gate. - If
post-merge-voice-gateFAILs withsource: transitions, fixoutline/transitions.mdviatransition-weaverand re-merge (do not patch the merged draft).
After PASS (mandatory style hygiene for survey/deep):
- Open
output/WRITER_SELFLOOP_TODO.mdand read## Style Smells. - If it flags opener cadence /
overviewnarration, runopener-variatoron the listed files. - If it flags count-based limitation slots (e.g.,
Two limitations ...), runlimitation-weaveron the listed files. - Otherwise (or after micro-fixes), run
style-harmonizeron the listedsections/*.mdfiles. - Before merge, run
evaluation-anchor-checkeron the settled H3 files so any remaining numeric claims keep same-sentence task/metric/constraint context. Treat this as the last section-level sweep, not as a post-audit patch. - Keep meaning + citations fixed; treat this as surface-level rewrite, not new content.
How to fix a failing H3 (semantic recipe)
- Use
tension_statement+thesisfrom the pack to rewrite paragraph 1 (end with the thesis). - Use
comparison_cardsto write explicit A-vs-B contrast sentences. - Use
evaluation_anchor_minimal/ protocol snippets to add task/metric/constraint context. - Use limitation hooks to add a real caveat (not boilerplate).
Paper voice repairs (high-impact, low-risk)
Narration opener -> content claim:
- Bad:
This subsection surveys ... - Better: start with a tension/decision/lens sentence, then end paragraph 1 with the thesis.
Slide navigation -> argument bridge:
- Bad:
Next, we move from X to Y. - Better:
Having established X, we can now examine how Y changes the trade-offs under comparable protocols.
Meta "survey should" -> literature-facing observation:
- Bad:
Therefore, survey comparisons should ... - Better:
Across reported protocols, ... varies, which makes ... fragile unless ...
Disclaimer spam -> one policy paragraph + local caveat only when needed:
- Keep evidence policy once in front matter; delete repeated "abstract-only" boilerplate inside H3.
Stop conditions (when rewriting is the wrong move)
Stop and route upstream if:
- you cannot write a contrast or evaluation anchor without guessing
- the pack lacks benchmarks/metrics/protocol details needed for the subsection\x27s core claim
- fixing one H3 keeps forcing out-of-scope citations
Failure codes -> routing (how to read the gate)
The writer gate emits short issue codes. Treat them as routers and stop trying to pad prose around missing evidence.
First classify failures:
- Evidence substrate: packs/anchors/comparisons are too thin to execute argument moves without guessing. Route upstream (
evidence-selfloop). - Writing execution: packs are rich enough, but the section did not execute moves (thesis/contrast/eval/limitation). Rewrite locally.
- Voice contamination: narration/slide/pipeline voice. Rewrite locally (opener + bridges), do not touch citations.
- Citation hygiene: undefined keys / out-of-scope pressure. Fix citations/bindings or rewrite to in-scope; do not add new keys.
Quick map (common codes):
missing_sections_manifest,empty_sections_manifest,sections_missing_files: runsubsection-writer(create missing files + refresh manifest).sections_h3_has_headings: remove headings; H3 bodies are body-only.sections_intro_*,sections_related_work_*: rewrite front matter viafront-matter-writer(dense positioning + one methodology note).sections_h3_too_few_paragraphs,sections_h3_too_short: if the pack is rich, expand by executing contrasts + eval anchor + limitation; if the pack is thin, route toevidence-selfloop.sections_h3_missing_contrast: add explicit A-vs-B usingcomparison_cards; if cards are missing, route toevidence-selfloop(briefs/packs).sections_h3_missing_eval_anchor,sections_h3_missing_cited_numeric: add minimal protocol context (task/metric/constraint) in the same paragraph; if unknown, route upstream or weaken the claim.sections_h3_missing_limitation: add a subsection-specific limitation; if none exists in the pack, route upstream.sections_h3_narration_template_opener,sections_h3_slide_narration,sections_contains_pipeline_voice: rewrite openers/bridges to paper voice (no navigation commentary).sections_h3_evidence_policy_disclaimer_spam: delete repeats; keep evidence policy once in front matter.sections_cites_missing_in_bib: reruncitation-verifier(do not invent keys).sections_cites_outside_mapping: rewrite to in-scope OR fix mapping/bindings (C2/C4) and rebuild packs; do not patch in the merged draft.sections_h3_sparse_citations: if scope allows, plan adds viacitation-diversifierthen apply viacitation-injector; if scope is too tight, expand mapping/bindings upstream.
Script (optional; deterministic gate)
Quick Start
python .codex/skills/writer-selfloop/scripts/run.py --workspace workspaces/<ws>
All Options
--workspace <dir>--unit-id <U###>--inputs <semicolon-separated>--outputs <semicolon-separated>--checkpoint <C#>
Examples
- Generate an actionable TODO list for failing
sections/*.md:python .codex/skills/writer-selfloop/scripts/run.py --workspace workspaces/<ws>
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
thesis-compile-review
对中文毕业论文进行编译、warning 分级、模板模式检查、数据与引用复查,并把问题回写成可继续迭代的 review checklist。 **Trigger**: 毕业论文编译检查, thesis compile review, warning 分级, 终稿复查, main.pdf 检查. **Use when**: 论文已经回写到 TeX 交付层,需要确认是否真正达到“可提交”的质量,而不是只做到能编译。 **Skip if**: 还处于中间层重构阶段,`chapters/*.tex` 尚未形成稳定交付稿。 **Network**: none. **Guardrail**: 不在这里重构章节主线;如果发现结构问题,明确回退到上游修复。
front-matter-writer
Write the survey's front matter files (Abstract, Introduction, Related Work, Discussion, Conclusion) in paper voice, with high citation density and a single evidence-policy paragraph. **Trigger**: front matter writer, introduction writer, related work writer, abstract writer, discussion writer, conclusion writer, 引言, 相关工作, 摘要, 讨论, 结论. **Use when**: you are in C5 (prose allowed) and need the paper-like shell to stop the draft reading like stitched subsections. **Skip if**: `Approve C2` is missing in `DECISIONS.md`, or `citations/ref.bib` is missing. **Network**: none. **Guardrail**: no invented facts/citations; no pipeline jargon in final prose; no repeated evidence disclaimers; only use keys present in `citations/ref.bib`.
thesis-question-list
维护中文毕业论文的 `codex_md/question_list.md`:把本轮问题、边界、优先级、协作方案和验收口径结构化,作为整条 thesis pipeline 的控制面。 **Trigger**: 毕业论文问题清单, thesis question list, 论文修改清单, 本轮目标, 结构问题梳理, review问题整理. **Use when**: 你已经有一批材料或上一轮 review 结果,需要明确这一轮到底修什么、不修什么,并给后续重构与编译复查提供统一入口。 **Skip if**: 当前只是在做一次性局部措辞修改,且没有形成新一轮结构/证据/编译问题。 **Network**: none. **Guardrail**: 不在这里写正文;不把问题单写成长篇散文;每条问题必须可执行、可验收。
novelty-matrix
Create a novelty/prior-work matrix comparing the submission’s contributions against related work (overlaps vs deltas). **Trigger**: novelty matrix, prior-work matrix, overlap/delta, 相关工作对比, 新颖性矩阵. **Use when**: peer review 中评估 novelty/positioning,需要把贡献与相关工作逐项对齐并写出差异点证据。 **Skip if**: 缺少 claims(先跑 `claims-extractor`)或你不打算做新颖性定位分析。 **Network**: none (retrieval of additional related work is out-of-scope unless provided). **Guardrail**: 明确 overlap 与 delta;尽量给出可追溯证据来源(来自稿件/引用/作者陈述)。
protocol-writer
Write a systematic review protocol into `output/PROTOCOL.md` (databases, queries, inclusion/exclusion, time window, extraction fields). **Trigger**: protocol, PRISMA, systematic review, inclusion/exclusion, 检索式, 纳入排除. **Use when**: systematic review pipeline 的起点(C1),需要先锁定 protocol 再开始 screening/extraction。 **Skip if**: 不是做 systematic review(或 protocol 已经锁定且不允许修改)。 **Network**: none. **Guardrail**: protocol 必须包含可执行的检索与筛选规则;需要 HUMAN 签字后才能进入 screening。
rubric-writer
Write a rubric-based peer review report (`output/REVIEW.md`) using extracted claims and evidence gaps (novelty/soundness/clarity/impact). **Trigger**: rubric review, referee report, peer review write-up, 审稿报告, REVIEW.md. **Use when**: peer-review pipeline 的最后阶段(C3),已有 `output/CLAIMS.md` + `output/MISSING_EVIDENCE.md`(以及可选 novelty matrix)。 **Skip if**: 上游产物未就绪(claims/evidence gaps 缺失)或你不打算输出完整审稿报告。 **Network**: none. **Guardrail**: 给可执行建议(actionable feedback),并覆盖 novelty/soundness/clarity/impact;避免泛泛而谈。
Didn't find tool you were looking for?