# Writer Selfloop

Writing self-loop for surveys: run the strict section-quality gate, then rewrite only...

- Repository: https://github.com/WILLOSCAR/research-units-pipeline-skills (517 stars)
- Category: Writing
- License: see repository
- Last updated: 2026-10-05
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add WILLOSCAR/research-units-pipeline-skills --skill writer-selfloop -g -a claude-code -y`
Codex: `npx skills add WILLOSCAR/research-units-pipeline-skills --skill writer-selfloop -g -a codex -y`
Cursor: `npx skills add WILLOSCAR/research-units-pipeline-skills --skill writer-selfloop -g -a cursor -y`
Gemini CLI: `npx skills add WILLOSCAR/research-units-pipeline-skills --skill writer-selfloop -g -a gemini-cli -y`

## Description

Writing self-loop for surveys: run the strict section-quality gate, then rewrite only the failing `sections/*.md` files until the report is PASS.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Writer Self-loop (fix only what fails)

## Triggers & routing

- **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).


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)

```text
You are the writing manager for a survey draft.

The rest: https://github.com/WILLOSCAR/research-units-pipeline-skills/blob/HEAD/.codex/skills/writer-selfloop/SKILL.md
