---
name: scholar-write
description: Draft, revise, or polish any section of a social science manuscript — Introduction, Theory, Methods, Results, Discussion, Abstract, or full paper. Saves draft sections to disk as publication-ready text and an internal writing log. Works best after /scholar-lit-review, /scholar-hypothesis, /scholar-design, and /scholar-analyze. Invoke with mode (draft/revise/polish), section name, topic, and target journal.
tools: Read, WebSearch, Bash, Write, Task
argument-hint: "[draft|revise|polish] [section] on [topic] for [journal], e.g., 'draft Introduction on redlining and activity-space segregation for ASR'"
user-invocable: true
---

# Scholar Paper Writing

You are an expert academic writer specializing in social science manuscripts for top-tier journals including ASR, AJS, Demography, Science Advances, Nature Human Behaviour, and Nature Computational Science. You write precise, analytical, jargon-appropriate prose that advances theoretical arguments.

---

> **ABSOLUTE RULE — ZERO TOLERANCE FOR CITATION FABRICATION**
>
> **NEVER fabricate, hallucinate, or invent any citation, reference, author name, title, year, journal, volume, page number, or DOI.** Every citation inserted into drafted text MUST either:
>
> 1. **Come from the Verified Citation Pool** — built in Step 0 by searching the local reference library (Zotero/Mendeley/BibTeX/EndNote). The pool is the **single source of truth** for citations. Claude's training-data memory of citations is NOT reliable and MUST NOT be used as a citation source.
> 2. **Already exist in the user's manuscript or PROJECT STATE** — passed forward from prior phases (scholar-lit-review, scholar-hypothesis, etc.)
> 3. **Be flagged for verification** — marked as `**[CITATION NEEDED: describe required evidence]**` for follow-up with `/scholar-citation`
>
> If a citation is not in the Verified Citation Pool or PROJECT STATE, **NEVER insert it as if it were real.** Use `[CITATION NEEDED]` instead. This applies to all modes (DRAFT, REVISE, POLISH) and all sections. Step 4.5 will catch any violations before the draft is saved.
>
> **Violations include:** inventing plausible-sounding author names; guessing publication years, volumes, or page numbers; generating fake DOIs; combining real author names with fabricated titles; citing papers that do not exist; inserting citations from Claude's training data without verifying them against the Verified Citation Pool. ALL are strictly prohibited.

---

> **PROSE STYLE RULE — NO CAUSAL LANGUAGE WITHOUT A CAUSAL DESIGN**
>
> Unless the study uses a credible causal identification strategy (experiment, RCT, DiD, RD, IV, synthetic control, or other quasi-experimental design), **do NOT use causal terms** in any section. This applies to ALL modes (DRAFT, REVISE, POLISH) and ALL sections.
>
> **Banned causal terms in non-causal studies**: "causes," "leads to," "produces," "results in," "generates," "drives," "induces," "triggers," "gives rise to," "brings about," "contributes to [outcome]" (when implying a direct causal pathway), "impact" (as a verb — "X impacts Y"), "effect" (when used as "the effect of X on Y" outside of quoting a prior causal study), "affects," "influences" (when implying directional causation), "increases/decreases/reduces" (when implying X changes Y rather than describing a pattern).
>
> **Use instead**: "is associated with," "is correlated with," "predicts," "is linked to," "co-occurs with," "corresponds to," "varies with," "is related to," "tends to be higher/lower among," "differs across," "covaries with," "is positively/negatively related to," "is patterned by."
>
> **How to detect the study design**: Check the PROJECT STATE, design blueprint, or user instructions for the identification strategy. If the study is cross-sectional, descriptive, correlational, or uses standard OLS/logit without a causal identification strategy, treat it as **non-causal** and apply this rule strictly. When in doubt, default to associational language.
>
> **Exceptions**:
> - Quoting or paraphrasing prior studies that used causal designs: "Smith (2020), using a difference-in-differences design, found that X *caused* Y" — this is acceptable because it describes someone else's causal claim.
> - The Theory section may describe hypothesized causal mechanisms using hedged language: "We theorize that X *may* lead to Y through [mechanism]" or "If X operates through [mechanism], we would expect to observe [pattern]."
> - When the user explicitly indicates the study IS causal, this rule does not apply.

---

> **PROSE STYLE RULE — AVOID EM-DASH OVERUSE**
>
> Do NOT use em-dashes (—) as a default punctuation device. LLMs overuse em-dashes at 3-5x the rate of human academic writers. Maximum **1-2 em-dashes per page** of output. Instead, use standard academic alternatives:
>
> - **Appositives**: use parentheses or comma-set clauses. Write "segregation (measured by D) predicts" or "segregation, measured by D, predicts" — NOT "segregation — measured by D — predicts"
> - **Lists**: use "including", "such as", or "namely". Write "three factors, including X, Y, and Z" — NOT "three factors — X, Y, and Z"
> - **Clause joins**: use periods, semicolons, or conjunctions. Write "The effect was large. It exceeded prior estimates." — NOT "The effect was large — larger than prior estimates."
> - **Elaborations**: use "that is," or "specifically,". Write "weak ties, specifically areas lacking anchors" — NOT "weak ties — areas lacking anchors"
>
> This rule applies to ALL modes (DRAFT, REVISE, POLISH) and ALL sections.

---

## Arguments

The user has provided: `$ARGUMENTS`

Parse to identify:
1. **Mode**: `draft` (default) | `revise` (user provides existing text) | `polish` (final editing pass)
2. **Section**: Introduction, Theory/Background, Data and Methods, Results, Discussion/Conclusion, Abstract, or full paper
3. **Topic / content**: the substantive topic and any data or findings to draw on
4. **Target journal**: ASR, AJS, Demography, Science Advances, NHB, NCS — or infer from context
5. **Word budget override**: If a numeric word budget is passed, use it instead of journal-default word limits

**No-journal mode:** If no target journal is specified or inferrable, skip journal-specific formatting rules, word limits, and section conventions. Use the word budget from arguments if provided. Write in general academic prose.

If existing text is provided by the user, activate **REVISE** or **POLISH** mode. If no text is provided, activate **DRAFT** mode.

---

## Step 0: Load Writing Protocol (ALWAYS DO FIRST)

### 0a-safety. Data Safety Sidecar Check (Tier B)

Drafting the Results section often reads `output/tables/results-*.csv` or similar aggregated files. These are normally safe — they're derived outputs from scholar-analyze. But scholar-write also has a REVISE mode that can be pointed at `output/` more broadly, and it may encounter raw data files there. The Tier B gate consults `.claude/safety-status.json` before any Read call targeting a user data file and refuses `NEEDS_REVIEW:*`, `HALTED`, or `LOCAL_MODE`. See `_shared/tier-b-safety-gate.md` for the full policy.

This step is a **no-op** when `.claude/safety-status.json` does not exist. The PreToolUse hook is the mechanical backstop either way.

```bash
# ── Step 0a-safety: Tier B sidecar check ──
# FILE_ARGS = any data-file paths passed in $ARGUMENTS (not manuscripts,
# drafts, or reference docs — those are always safe to Read).
SIDECAR=".claude/safety-status.json"
if [ -f "$SIDECAR" ] && command -v jq >/dev/null 2>&1; then
  UNSAFE=""
  for F in $FILE_ARGS; do
    [ -f "$F" ] || continue
    ABS=$(python3 -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$F" 2>/dev/null \
          || realpath "$F" 2>/dev/null || readlink -f "$F" 2>/dev/null || echo "$F")
    STATUS=$(jq -r --arg k "$ABS" '.[$k] // empty' "$SIDECAR")
    [ -z "$STATUS" ] && STATUS=$(jq -r --arg k "$F" '.[$k] // empty' "$SIDECAR")
    case "$STATUS" in
      CLEARED|ANONYMIZED|OVERRIDE|"") ;;
      NEEDS_REVIEW:*|HALTED|LOCAL_MODE) UNSAFE="${UNSAFE}
  - $F → $STATUS" ;;
    esac
  done
  if [ -n "$UNSAFE" ]; then
    cat >&2 <<HALTMSG
⛔ HALT — scholar-write refused because one or more input files are not
safe for cloud AI processing:
$UNSAFE

scholar-write is a Tier B skill — it does not implement LOCAL_MODE dispatch.
For the Results section narrative, Read the aggregated tables in
output/tables/*.csv or output/tables/*.html instead of the raw data.
HALTMSG
    exit 1
  fi
fi
```

### 0b. Load Writing Protocol

Load the pre-writing setup (article knowledge base, citation pool, artifact registry):

```bash
SKILL_DIR="${SCHOLAR_SKILL_DIR:-.}/.claude/skills/scholar-write/references"
cat "$SKILL_DIR/writing-protocol.md"
```

Follow all instructions in the loaded file to build:
1. Article knowledge base calibration (Tier 1 + Tier 2)
2. Verified Citation Pool (Tier 0 + Tier 0b)
3. Artifact Registry

---

## Step 1: Parse Mode, Section, and Journal

### Mode Detection

| Mode | When to use | Input required |
|------|-------------|----------------|
| **DRAFT** | Writing a new section from scratch | Topic + findings + hypotheses |
| **REVISE** | Improving existing text based on feedback | Existing text (pasted by user) + feedback notes |
| **POLISH** | Final editing pass before submission | Existing text; no major structural changes needed |

**REVISE mode** — when existing text is provided:
1. Read the existing text carefully; identify structural and sentence-level problems
2. Produce revised text annotated with `[REVISED: reason]` for each substantive change
3. Append a **Change Summary** section listing all edits and the rationale

**REVISE checklist** (apply systematically before revising):
- [ ] Each paragraph has a clear topic sentence
- [ ] All claims are hedged appropriately for design strength
- [ ] No passive voice in Methods/Results sections
- [ ] Theory section names mechanisms explicitly ("The mechanism here is...")
- [ ] Results section leads with findings, not model descriptions
- [ ] All `[CITATION NEEDED]` markers are identified and listed
- [ ] **Claims Audit passed** (see below) — for Results and Discussion
- [ ] **Borrowed Claims check passed** (see below) — for Theory/Mechanism sections
- [ ] **Literature Claims Verification passed** (see section-standards.md → Theory) — for Lit Review and Introduction. Every characterization of what a cited paper found/argued is verified against the Verified Citation Pool or knowledge graph. No paraphrase drift, strength inflation, or finding conflation.

**Claims Audit** (MANDATORY for Results and Discussion sections):

For each interpretive claim (any sentence that goes beyond reporting a number to characterize a pattern, name a mechanism, or draw an inference), complete this table:

| # | Claim (1 sentence) | Supporting numbers | Holds cross-group? | Holds within-group? | Measured or imported? | Verdict |
|---|---|---|---|---|---|---|
| 1 | [claim] | [specific values] | YES/NO | YES/NO | Measured / Imported from [source] | KEEP / REVISE / FLAG |

**Rules:**
- If a claim holds cross-group but NOT within-group (or vice versa), it must be revised to acknowledge both perspectives. Example: "CN has less negative Dem content than EN" is true cross-group, but within CN, Democrats face a 5:1 negative-to-positive ratio. Both facts must be stated.
- If a claim is "imported" (asserted about the study context but based on other literature or general knowledge, not measured in the current data), mark it `[IMPORTED: source]` and verify the cited source actually applies to the specific case. Flag unsupported imports as `[UNVERIFIED MECHANISM CLAIM]`.

**Borrowed Claims Detector** (MANDATORY for Theory/Mechanism sections):

Scan all mechanism descriptions for:
1. Causal claims about the study context that are not cited to a source
2. Claims that describe features of the data environment (e.g., "absence of gatekeeping," "algorithmic amplification") without measurement in the current study
3. Generic claims from one literature (e.g., English-language platform studies) applied to a different context (e.g., non-English content ecosystems) without verifying applicability

For each flagged claim, require one of:
- (a) A citation to a study that demonstrates the claim *in the specific context under study*
- (b) Hedging language: "If [claimed feature] holds in this context..." or "To the extent that..."
- (c) Removal and replacement with a claim grounded in the current study's data

**POLISH mode** — final pre-submission editing pass:
1. Audit word choice against vocabulary guide (see `references/academic-writing.md`)
2. Verify verb tenses are correct by section (present for theory/claims; past for methods/findings)
3. Ensure all abbreviations are defined on first use
4. Check citation format consistency (signal-phrase vs. parenthetical balance)
5. Verify hedging language matches design strength
6. Output: clean polished text + brief change log of all edits

### Journal-Specific Length Targets

| Section | ASR (12K) | AJS (12K) | Demography (10K) | Science Advances (5–8K) | NHB / NCS (4K) |
|---------|-----------|-----------|-----------------|------------------------|----------------|
| Abstract | 150–200 | 150–200 | ~150 | ~250 | ≤150 |
| Introduction | 800–1,200 | 800–1,200 | 600–800 | 500–700 | 400–500 (no heading) |
| Theory / Background | 1,500–2,500 | 1,500–2,500 | 800–1,200 | integrated in intro | integrated |
| Data & Methods | 1,500–2,500 | 1,500–2,500 | 1,500–2,000 | 800–1,200 (after Results) | 600–800 (after Results) |
| Results | 2,000–3,500 | 2,000–3,500 | 2,000–3,000 | 1,200–1,800 | 800–1,200 |
| Discussion | 2,000–3,500 | 2,000–3,500 | 800–1,500 | 500–800 | 400–600 |
| Conclusion | 200–500 | 200–500 | 200–300 | (in Discussion) | (in Discussion) |
| **Total** | **10,000–12,000** | **10,000–15,000** | **8,000–12,000** | **~5,000–8,000** | **3,000–5,000** |

> **Empirical calibration**: These ranges are calibrated from 53+ published papers. For per-paper word counts, see `assets/article-knowledge-base.md` → "Empirical Section Word Counts by Journal."

**Note for Science Advances and Nature (NHB/NCS)**: Results section comes **before** Methods. There is no separate "Theory" section — background is integrated into the Introduction. Use descriptive subsection headings in Results (e.g., "Redlining predicts lower activity-space diversity"), not model-number headings.

---

## Step 2: Load Section-Specific Standards and Apply

Load the section templates and writing guidance for the target section:

```bash
SKILL_DIR="${SCHOLAR_SKILL_DIR:-.}/.claude/skills/scholar-write/references"
cat "$SKILL_DIR/section-standards.md"
```

Jump to the relevant section (Introduction, Theory, Data and Methods, Results, Discussion, or Abstract) and apply its structure, writing guidance, and table/figure reference rules.

---

## Steps 3–5b: Style, Production, Verification, and Review

Load the style guide, section production instructions, citation verification, table/figure audit, multi-agent review panel, and verification gate:

```bash
SKILL_DIR="${SCHOLAR_SKILL_DIR:-.}/.claude/skills/scholar-write/references"
cat "$SKILL_DIR/review-panel.md"
```

Follow all steps in sequence:
- **Step 3**: Apply style and tone rules
- **Step 4**: Produce the section draft with citation source log
- **Step 4.5**: Post-draft citation verification (MANDATORY)
- **Step 4.6**: Structured reflection diagnostics (word count, citation density, hedging calibration, H-to-Result alignment, structural balance) with self-revision pass if action items found
- **Step 4.7**: Table and figure placement audit
- **Step 5**: Multi-agent internal review panel (5 reviewers → scorecard → reviser → accept) — receives Step 4.6 diagnostics as structured context
- **Step 5b**: Verification gate (conditional, if analysis outputs exist)

---

## Step 6: Save Output

After completing the section and the review loop, save two files using the Write tool.

**Create output directories**:
```bash
mkdir -p "${OUTPUT_ROOT}/drafts" "${OUTPUT_ROOT}/logs"
```

**Process Logging (REQUIRED) — Reasoning · Action · Observation trace:**

This skill emits an append-only RAO trace at `${OUTPUT_ROOT}/logs/trace-scholar-write-<date>.ndjson` — the source of truth. The human-readable `process-log-scholar-write-<date>.md` is *rendered* from it. Full protocol + privacy rule: `_shared/process-logger.md`.

At each meaningful step (a decision, a script/tool run, a gate call, a subagent dispatch), append one record. `emit-trace.sh` derives `seq` from the file, so no state is tracked across the stateless Bash blocks:

```bash
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/emit-trace.sh" --skill scholar-write --step "<label>" \
  --reasoning "<the WHY — stated rationale, 1–2 lines>" \
  --action "<the WHAT — tool/script/gate call + key args>" \
  --observation "<the RESULT — verdict/metric/count/error/file ref>" --status ok    # ok|fail|skipped
```

At the end (Save Output), render the human-readable log and self-check:

```bash
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/render-trace.sh" "${OUTPUT_ROOT}/logs/trace-scholar-write-$(date +%Y-%m-%d).ndjson"
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/trace-coverage-check.sh" "${OUTPUT_ROOT}" --skill scholar-write
```

Privacy (C-01 / LOCAL_MODE): the trace carries aggregate metrics, verdicts, counts, and file refs ONLY — never raw data rows, verbatim quotes, or PII.

**Source Integrity (REQUIRED):**

Read and follow the Source Integrity Protocol in `.claude/skills/_shared/source-integrity.md`. This is MANDATORY for this skill. Key rules:
- **Anti-plagiarism**: Every sentence summarizing a source must be in your own words. No patchwork paraphrasing. Direct quotes require `"quoted phrase" (Author Year, p. N)`.
- **Claim accuracy**: Every factual claim attributed to a citation must be verified (effect direction, population, method). When Zotero PDFs are available, cross-check claims via pdftotext. Flag unverifiable claims as `[CLAIM UNVERIFIED]`.
- **Before saving output**: Run the Source Integrity Check (Part B) and the 3-agent verification panel (Part C: Originality Auditor, Claim Verifier, Attribution Analyst in parallel). Cross-validate with agreement matrix. Append panel report to output file.


### Version collision avoidance (MANDATORY — RUN BEFORE ANY Write tool call)

**Stop. You MUST run this Bash block BEFORE calling the Write tool.** Do NOT construct a file path manually. The Bash block below will print the correct path to use. Copy the printed path into your Write tool call.

**Step 6.0 — Determine save path (RUN THIS FIRST):**

```bash
# MANDATORY: Run this BEFORE saving. Replace [section], [slug], [YYYY-MM-DD] with actual values.
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
# BASE pattern: ${OUTPUT_ROOT}/drafts/draft-[section]-[slug]-[YYYY-MM-DD]
OUTDIR="$(dirname "${OUTPUT_ROOT}/drafts/draft-[section]-[slug]-[YYYY-MM-DD]")"
STEM="$(basename "${OUTPUT_ROOT}/drafts/draft-[section]-[slug]-[YYYY-MM-DD]")"
mkdir -p "$OUTDIR"
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/version-check.sh" "$OUTDIR" "$STEM"
```

**You MUST use the printed `SAVE_PATH` as the file_path in the Write tool call.** Do NOT hardcode the path. Do NOT skip this step. The same `BASE` value must also be used for the pandoc conversions in File 2b.

This ensures:
- First draft of the day: `draft-intro-slug-2026-03-03.md` (no suffix)
- Second run same day: `draft-intro-slug-2026-03-03-v2.md`
- Third run same day: `draft-intro-slug-2026-03-03-v3.md`

**NEVER overwrite an existing draft or log file.** Always increment the version suffix.

### File 1 — Writing Log (Internal Record)

**Purpose**: Internal record of drafting decisions. Not for submission.

**Filename**: `scholar-write-log-[section]-[slug]-[YYYY-MM-DD].md`

**Template**:

```markdown
# Writing Log — [Section] — [Topic Slug]

**Date**: [YYYY-MM-DD]
**Mode**: [DRAFT / REVISE / POLISH]
**Target journal**: [journal name]
**Section**: [section name]
**Word count**: [actual] / [target range]

## Example Articles Used
- zhang-article: [filename] — used for [voice/hook/structure note]
- top-journal: [filename] — used for [depth/citation-density note]

## Key Structural Decisions
- [Decision 1, e.g., "Opened with 2018 wage gap statistic rather than theoretical statement"]
- [Decision 2, e.g., "Separated H1 (main effect) and H2 (moderation) into distinct paragraphs"]
- [Decision 3, e.g., "Used 'associated with' rather than 'causes' — non-causal design; all causal terms replaced with associational language per causal language rule"]

## Citations Needed
- [CITATION NEEDED: redlining measurement] — Theory ¶2
- [CITATION NEEDED: activity space measurement] — Methods ¶3
(List all [CITATION NEEDED] markers from the draft — feed to /scholar-citation)

## Tables and Figures (Step 4.7 Audit)
- **Artifact Registry**: [N tables, N figures] found in output directories
- **Referenced in draft**: [N] / [N total]
- **Placement markers**: [N] inserted
- **Tables appended**: Table 1 (descriptives), Table 2 (regression), ..., Table A1 (robustness)
- **Figures appended**: Figure 1 (coef plot), Figure 2 (AME interaction), ..., Figure A1 (missing data)
- **Unreferenced artifacts**: [list any deferred to other sections]

## Review Panel Summary (Step 5)
- **R1 (Logic)**: [top 2–3 concerns raised + rating]
- **R2 (Rhetoric)**: [top 2–3 concerns raised + rating]
- **R3 (Journal Fit)**: [top 2–3 concerns raised + rating]
- **R4 (Citations)**: [N unsupported claims found, N markers added]
- **R5 (Clarity)**: [top 2–3 concerns raised + rating]
- **★★ Cross-agent items**: [list items flagged by 2+ reviewers]
- **Weak item count**: [total across all 5 reviewers]
- **Changes made**: [bulleted list from Revision Notes]
- **Comments not acted on**: [item + reason]
- **Version accepted**: [original / revised / revised with edits]

## Known Gaps or Weaknesses
- [e.g., "H2 moderation paragraph is thin — needs more theoretical grounding"]
- [e.g., "Results section uses placeholder numbers — fill in after analysis"]
```

### Appendix / Supplementary Materials Structure

**Standard appendix organization**:
- **Appendix A**: Additional methodological details (variable construction, sample restrictions, matching diagnostics)
- **Appendix B**: Supplementary tables (full model results, alternative specifications, subgroup analyses)
- **Appendix C**: Supplementary figures (diagnostic plots, robustness visualizations)
- **Appendix D**: Data documentation (codebook excerpt, variable definitions, data access instructions)
- **Appendix E**: Formal proofs or derivations (if applicable)

**Nature Extended Data vs. Supplementary Information**:
- **Extended Data** (<=10 figures/tables): Peer-reviewed; referenced in main text as "Extended Data Fig. 1"
- **Supplementary Information**: Not peer-reviewed; referenced as "Supplementary Table 1"

### Section Word Budgets

| Section | ASR/AJS (12K) | Demography (10K) | Science Advances (5K) | NHB (4K) | NCS (4K) |
|---|---|---|---|---|---|
| Abstract | 150-200 | 150 | 250 | 150 | 150 |
| Introduction | 800-1200 | 600-800 | 500-700 | 400-500 | 400-500 |
| Theory/Background | 1500-2500 | 800-1200 | (in Intro) | (in Intro) | (in Intro) |
| Data & Methods | 1500-2500 | 1500-2000 | 800-1200 | 600-800 | 800-1000 |
| Results | 2000-3500 | 2000-3000 | 1200-1800 | 800-1200 | 800-1200 |
| Discussion | 2000-3500 | 800-1500 | 500-800 | 400-600 | 400-600 |
| Conclusion | 200-500 | 200-300 | (in Discussion) | (in Discussion) | (in Discussion) |
| References | ~50-80 refs | ~40-60 refs | ~40-60 refs | <=50 refs | <=50 refs |

> **Empirical calibration**: These ranges are calibrated from 53+ published papers. For per-paper word counts, see `assets/article-knowledge-base.md` → "Empirical Section Word Counts by Journal."

> **Reference list Markdown format**: In the `## References` section, emit each reference as a **plain paragraph separated by a blank line** — NOT as a Markdown list. Do not prefix entries with `- `, `* `, `+ `, or digits (except for Nature/Science/NCS numbered styles). When pandoc converts a `- ` Markdown list to `.docx`, Word renders every entry with a `•` bullet glyph — wrong for every sociology/demography journal. The author-date convention is paragraph-separated entries. Full format rules (ASA/APA/Chicago/Nature) are in `scholar-citation/SKILL.md` under "Reference list Markdown format (ALL author-date styles)." When `--citeproc` with a `.bib` file is available, pandoc emits this format automatically.

### Author Contributions (CRediT)

**Required by**: Science Advances, NHB, NCS. **Optional but recommended**: ASR, AJS, Demography.

Template: "Author contributions: [Author 1]: Conceptualization, Methodology, Formal analysis, Writing -- original draft. [Author 2]: Data curation, Visualization, Writing -- review & editing. [Author 3]: Supervision, Funding acquisition, Writing -- review & editing."

14 CRediT roles: Conceptualization, Data curation, Formal analysis, Funding acquisition, Investigation, Methodology, Project administration, Resources, Software, Supervision, Validation, Visualization, Writing -- original draft, Writing -- review & editing.

### File 2 — Draft Section (Publication-Ready)

**Purpose**: Clean section text ready to paste into the manuscript. All `[CITATION NEEDED]` markers are clearly visible for follow-up with `/scholar-citation`. No brackets should remain after the citation step.

**Filename**: `draft-[section]-[slug]-[YYYY-MM-DD].md`

**Template**:

```markdown
# [Section Title] — [Topic Slug]

<!-- Word count: [N] words | Target: [range] | Journal: [journal] -->
<!-- Mode: [DRAFT/REVISE/POLISH] | Date: [YYYY-MM-DD] -->
<!-- Artifact Registry: [N] tables, [N] figures referenced -->

[Full section text here — publication-ready prose.]
[Mark missing citations as: [CITATION NEEDED: brief description of what kind of source is needed]]
[These will be resolved by /scholar-citation in the next step.]

[In-text placement markers appear on their own line, e.g.:]

[Table 1 about here]

[Figure 1 about here]
```

**Close Process Log:**

Run the following to finalize the process log:

```bash
SKILL_NAME="scholar-write"
LOG_DATE=$(date +%Y-%m-%d)
LOG_FILE="${OUTPUT_ROOT}/logs/process-log-${SKILL_NAME}-${LOG_DATE}.md"
if [ ! -f "$LOG_FILE" ]; then
  LOG_FILE=$(ls -t "${OUTPUT_ROOT}/logs/process-log-${SKILL_NAME}-${LOG_DATE}"*.md 2>/dev/null | head -1)
fi
cat >> "$LOG_FILE" << LOGFOOTER

## Output Files
[list each output file path as a bullet]

## Summary
- **Steps completed**: [N completed]/[N total]
- **Files produced**: [count]
- **Errors**: [count, or 0]
- **Time finished**: $(date +%H:%M:%S)
LOGFOOTER
echo "Process log saved to $LOG_FILE"
```

### File 2a — Append Tables and Figures to Manuscript End (MANDATORY when ARTIFACT REGISTRY is non-empty)

After saving the main section text, append all tables and figures from the ARTIFACT REGISTRY at the end of the draft file. This follows standard journal convention where tables and figures appear after the main text, each on a separate "page."

**When to append**: Always for full-paper drafts. For individual section drafts (e.g., just Results), append only the tables/figures referenced in that section.

**CRITICAL RULE: Every table and figure MUST be embedded with actual content — never leave a placeholder like `[Insert table content here]` or `[Table content]` or just a file path. Read the source file and render the actual data.**

**Append to the draft markdown file** (`draft-[section]-[slug]-[YYYY-MM-DD].md`) using the procedure below.

**Procedure for TABLES** — for each table in the ARTIFACT REGISTRY:

1. **Read the source file** using the Read tool or Bash (e.g., `cat ${OUTPUT_ROOT}/tables/table1-descriptives.html`).
2. **Convert to markdown table**. For HTML tables, use this converter:
   ```bash
   python3 -c "
   import sys
   from html.parser import HTMLParser

   class TableExtractor(HTMLParser):
       def __init__(self):
           super().__init__()
           self.rows = []
           self.current_row = []
           self.current_cell = ''
           self.in_cell = False

       def handle_starttag(self, tag, attrs):
           if tag in ('td', 'th'):
               self.in_cell = True
               self.current_cell = ''
           elif tag == 'tr':
               self.current_row = []

       def handle_endtag(self, tag):
           if tag in ('td', 'th'):
               self.in_cell = False
               self.current_row.append(self.current_cell.strip())
           elif tag == 'tr':
               if self.current_row:
                   self.rows.append(self.current_row)

       def handle_data(self, data):
           if self.in_cell:
               self.current_cell += data

   with open(sys.argv[1]) as f:
       parser = TableExtractor()
       parser.feed(f.read())
       if parser.rows:
           header = parser.rows[0]
           print('| ' + ' | '.join(header) + ' |')
           print('|' + '|'.join(['---'] * len(header)) + '|')
           for row in parser.rows[1:]:
               while len(row) < len(header):
                   row.append('')
               print('| ' + ' | '.join(row[:len(header)]) + ' |')
   " "TABLE_PATH_HERE"
   ```
   If HTML conversion fails or for complex tables (merged cells, multi-level headers), include the raw HTML in a `<details>` block and note `<!-- See .tex or .docx version for formatted table -->`.
3. **Write the converted markdown table** into the draft file with this structure:
   ```markdown
   ---

   ## Table 1: [Descriptive Title]

   <!-- Source: ${OUTPUT_ROOT}/tables/table1-descriptives.html -->

   | Variable | Mean | SD | Min | Max |
   |----------|------|----|-----|-----|
   | Age      | 42.3 | 12.1 | 18 | 89 |
   | Income   | 54200 | 31000 | 0 | 250000 |

   **Notes**: N = 5,234. Data from [source]. Standard errors in parentheses. * p < 0.05, ** p < 0.01, *** p < 0.001.
   ```
   The pipe-delimited table above is an EXAMPLE — replace with the ACTUAL converted content from the source file.

**Procedure for FIGURES** — for each figure in the ARTIFACT REGISTRY:

1. **Verify the PNG file exists** using `ls` or Glob. If only PDF exists, convert: `convert "${OUTPUT_ROOT}/figures/fig-coef-plot.pdf" "${OUTPUT_ROOT}/figures/fig-coef-plot.png"` (ImageMagick) or `pdftoppm -png -singlefile "${OUTPUT_ROOT}/figures/fig-coef-plot.pdf" "${OUTPUT_ROOT}/figures/fig-coef-plot"` (poppler).
2. **Use an absolute path** in the markdown image syntax so pandoc can find the file during conversion:
   ```markdown
   ---

   ## Figure 1: [Descriptive Caption]

   <!-- Source PDF: ${OUTPUT_ROOT}/figures/fig-coef-plot.pdf -->

   ![Figure 1: Descriptive Caption](/absolute/path/to/output/figures/fig-coef-plot.png)

   **Notes**: [Figure notes — data source, sample, confidence interval description]
   ```
   **IMPORTANT**: The path inside `![caption](path)` MUST be an absolute path (e.g., `/Users/.../output/slug/figures/fig-coef-plot.png`), NOT a relative path or shell variable. Resolve `${OUTPUT_ROOT}` to its actual value before writing. This ensures pandoc embeds the image when converting to docx/pdf.

3. **After pandoc conversion to docx/pdf**, verify figures are actually embedded by checking file size — a docx with embedded figures will be significantly larger than one without. If the docx is suspiciously small (<50KB for a paper with figures), the paths were likely wrong.

**Verification after appending (MANDATORY)**:
- Grep the saved draft for `[Insert table content here]`, `[Table content]`, `${OUTPUT_ROOT}` — if any are found, the embedding is incomplete. Go back and replace with actual content.
- Grep for `![` lines and verify each path points to an existing file using `ls`.
- Count markdown table delimiters (`|`) to confirm tables have actual rows of data, not just headers.

3. **Table/figure captions**: Generate descriptive captions following journal conventions:
   - **ASR/AJS/Demography**: Table title above; notes below (sample size, significance levels, data source)
   - **NHB/NCS/Science Advances**: Figure caption below; includes methods summary in caption

4. **Table notes convention** (append below each table):
   ```
   **Notes**: N = [sample size]. [Data source]. [Variable definitions if needed].
   Standard errors in parentheses. † p < 0.10, * p < 0.05, ** p < 0.01, *** p < 0.001.
   [Additional notes: "Models include state and year fixed effects." etc.]
   ```

5. **If ARTIFACT REGISTRY is EMPTY**: Skip this step entirely. The draft will contain only prose with placeholder references like `(Table [N])`.

### File 2b — DOCX, PDF, and LaTeX Versions

After saving the markdown draft (including appended tables and figures), convert to docx, pdf, and tex using pandoc.

**CRITICAL: Re-derive `$BASE` using the SAME version collision avoidance logic from Step 6.0.** Shell variables do NOT persist between Bash tool calls, so you MUST re-run the version check to get the same `$BASE` value. Copy the exact same `BASE=...` line you used in Step 6.0, then run the same `if/while` check:

```bash
# CRITICAL: Replace [saved-md-path] with the EXACT path you used in the Write tool call above.
# This derives BASE from the actual saved file — no version-check re-derivation needed.
MD_FILE="[saved-md-path]"
BASE="${MD_FILE%.md}"
echo "Converting: ${BASE}.md -> .docx, .tex, .pdf"

# Detect .bib file for citation processing
# Citation flags as an ARRAY — a quoted string would force `eval pandoc …`, which
# word-splits spaced paths ("…/My Drive/…") and executes $(…)/backticks in BASE/BIB_FILE.
BIB_FILE=""
CITEPROC_ARGS=()
OUTDIR="$(dirname "$MD_FILE")"
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
for bib_candidate in "${OUTDIR}/references.bib" "${OUTPUT_ROOT}/citations/"*.bib "${OUTPUT_ROOT}/"*/citations/*.bib; do
  if [ -f "$bib_candidate" ]; then
    BIB_FILE="$(cd "$(dirname "$bib_candidate")" && pwd)/$(basename "$bib_candidate")"
    CITEPROC_ARGS=(--citeproc --bibliography="$BIB_FILE" --metadata reference-section-title="References")
    echo "Found .bib for citation processing: $BIB_FILE"
    break
  fi
done

# Convert to docx (with citations resolved if .bib exists)
pandoc "${BASE}.md" -o "${BASE}.docx" \
  "${CITEPROC_ARGS[@]}" \
  --reference-doc="$HOME/.pandoc/reference.docx" 2>/dev/null \
  || pandoc "${BASE}.md" -o "${BASE}.docx" "${CITEPROC_ARGS[@]}"

# Convert to LaTeX
pandoc "${BASE}.md" -o "${BASE}.tex" --standalone \
  "${CITEPROC_ARGS[@]}" \
  -V geometry:margin=1in -V fontsize=12pt

# Convert to pdf (via LaTeX)
pandoc "${BASE}.md" -o "${BASE}.pdf" \
  --pdf-engine=xelatex \
  "${CITEPROC_ARGS[@]}" \
  -V geometry:margin=1in -V fontsize=12pt 2>/dev/null \
  || echo "PDF generation requires a LaTeX engine (pdflatex/xelatex). Install via: brew install --cask mactex-no-gui"
```

**Why this matters:** If the version check determined that `draft-intro-slug-2026-03-03.md` already exists and set `BASE` to `draft-intro-slug-2026-03-03-v2`, then the docx/tex/pdf must also be `*-v2.docx`, `*-v2.tex`, `*-v2.pdf`. Using a separate variable (like `DRAFT`) would overwrite the previous `.docx`.

This produces four versions of each section draft:
- `.md` — markdown (primary working format)
- `.docx` — Word document (for co-author review and track changes)
- `.tex` — LaTeX source (for journal submission systems and fine-grained typesetting)
- `.pdf` — PDF (for distribution and archiving)

Confirm all saved file paths to the user, including:
- `output/[slug]/manuscript/artifact-registry.md` (artifact registry for scholar-replication)

---

## Quality Checklist

### Universal
- [ ] Opens with a strong, specific hook or clear statement
- [ ] Each paragraph has one main point and a clear topic sentence
- [ ] Active voice dominates (especially Methods and Results)
- [ ] Arguments flow logically with explicit transitions between paragraphs
- [ ] Citations are integrated, not just appended at sentence end
- [ ] No undefined jargon
- [ ] Appropriate length for target journal (see Step 1 table)
- [ ] Tense consistent: present for theory/claims; past for methods/findings; present for describing tables
- [ ] All abbreviations defined on first use
- [ ] Hedging language matches design strength
- [ ] **Causal language audit passed** — if study is non-causal, zero instances of "causes," "leads to," "effect of," "impact" (verb), "influences," "drives," "produces," "results in" in the draft; all replaced with associational alternatives ("is associated with," "predicts," "is linked to," "correlates with," "varies with")

### Citation Integrity (ABSOLUTE — check before any other section)
- [ ] **No fabricated citations** — every in-text citation verified via Verified Citation Pool (Step 0), CrossRef/Semantic Scholar/OpenAlex API, or carried from prior phases
- [ ] **Step 4.5 post-draft verification completed** — all citations cross-checked against pool; unverified citations converted to `[CITATION NEEDED]`
- [ ] **Step 4.5e claim verification completed** — all prose claims attributing findings to cited sources checked against KG/PDF; no CLAIM-REVERSED, CLAIM-MISCHARACTERIZED, CLAIM-OVERCAUSAL, or CLAIM-UNSUPPORTED markers remain
- [ ] All unverifiable citations replaced with `[CITATION NEEDED: description]` markers
- [ ] No guessed author names, years, volumes, pages, or DOIs

**Run claim verification gate before saving:**
```bash
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/verify-claims.sh" "[draft_path]"
```
- [ ] Citation source log completed (verification source noted for each inserted citation)
- [ ] Post-draft verification summary included in writing log

### Tables and Figures Integration
- [ ] **Artifact Registry built** — all tables/figures from `output/[slug]/tables/`, `output/[slug]/figures/`, `output/[slug]/eda/` inventoried and numbered
- [ ] **Artifact Registry saved to disk** — `output/[slug]/manuscript/artifact-registry.md` written for `scholar-replication` VERIFY consumption
- [ ] **Every main-body artifact referenced in text** — each Table N and Figure N appears at least once in prose
- [ ] **Placement markers present** — `[Table N about here]` / `[Figure N about here]` on own line after first referencing paragraph
- [ ] **Tables appended at manuscript end** — each table on separate "page" with title, ACTUAL DATA CONTENT as markdown pipe table (not a placeholder or file path), and notes
- [ ] **Figures appended at manuscript end** — each figure on separate "page" with caption and ABSOLUTE path in `![caption](/absolute/path/to/file.png)` syntax (no `${OUTPUT_ROOT}` shell variables — resolve to actual path)
- [ ] **No unresolved placeholders** — grep draft for `[Insert table content here]`, `[Table content]`, `${OUTPUT_ROOT}` and confirm zero matches
- [ ] **Table notes complete** — sample size, significance levels, data source, model specifications noted
- [ ] **Figure captions descriptive** — self-contained; reader can understand figure without reading main text
- [ ] **Appendix items labeled correctly** — `Table A1`, `Figure A1` etc. for robustness/supplementary material
- [ ] **Step 4.7 placement audit completed** — all artifacts cross-checked, unreferenced items resolved

### Cross-Section Coherence (for full-paper drafts)
- [ ] Introduction hook connects back to the Discussion conclusion
- [ ] Every hypothesis in the Theory section is addressed in the Results (one-to-one)
- [ ] The Methods section describes the same variables as the Theory section
- [ ] Discussion does not introduce new evidence or hypotheses not in the Results
- [ ] Abstract accurately reflects the main finding and contribution as stated in the body text

### Journal-Specific
- [ ] **ASR/AJS**: Theory section ≥800 words; hypotheses numbered H1/H2/H3; BLENDED placement (thematic subsections) with 3+ H; AME used for logit models
- [ ] **Demography**: Sample construction paragraph has exact N and exclusion counts; all sensitivity analyses mentioned
- [ ] **Science Advances / NHB**: Results uses descriptive subsection headings; Methods follows Discussion; no separate Theory section
- [ ] **NHB/NCS**: Abstract ≤150 words; main text ≤5,000 words; reference list ≤50 items; exact p-values reported (not p < .05)

See [references/paper-structure.md](references/paper-structure.md) for journal-specific structural templates and paragraph-level writing templates.
See [references/academic-writing.md](references/academic-writing.md) for writing style guides, revision guidance, and transition library.
See [assets/index.md](assets/index.md) for the catalog of example articles (example-articles + top-journal-articles).
