- name
- rewrite-literature
- description
- Orchestrate a deep rewrite of Chapter 2 (Literature Review) using multi-agent pipeline with RAG-backed evidence
# Literature Review Rewrite Orchestrator
Rewrite Chapter 2 from scratch with deep extraction from ~20 cited papers. Uses a 5-phase pipeline with 7 specialized agents.
## Arguments
- `all` — Run the full 5-phase pipeline (default)
- `phase1` through `phase5` — Run a specific phase (assumes prior phases completed)
- `section N` — Draft only section 2.N (for iterating on one section)
## Workspace
All intermediate artifacts go in `thesis/chapters/.litreview_workspace/`. Create it at the start:
```bash
mkdir -p /Users/alessandro/Projects/Tesi/thesis/chapters/.litreview_workspace/drafts
```
## Target Structure (~400-500 lines)
```
Chapter 2: Literature Review
├── Intro paragraph (preview sections using \Cref)
├── 2.1 Automation and the Labor Market
│ ├── 2.1.1 The Task-Based Framework
│ ├── 2.1.2 Labor Market Polarization
│ ├── 2.1.3 Task Displacement and Rent Dissipation
│ └── 2.1.4 Bridge paragraph → politics
├── 2.2 Economic Shocks and Political Attitudes
│ ├── 2.2.1 The China Shock and Political Consequences
│ ├── 2.2.2 Automation and Voting Behavior
│ └── 2.2.3 Methodological Parallels (NEW)
├── 2.3 Mechanisms: From Economic Disruption to Political Change
│ ├── 2.3.1 The Economic Insecurity Thesis
│ ├── 2.3.2 The Cultural Backlash Thesis
│ ├── 2.3.3 Status Threat and the 2016 Election
│ ├── 2.3.4 Psychological Foundations (DEEPENED)
│ └── 2.3.5 Identity Threat as Integrating Framework (NEW)
└── 2.4 Contribution of This Thesis
```
---
## PHASE 1: RESEARCH (parallel)
Launch TWO agents in parallel using the Task tool:
### Agent 1: Extraction Assembler (sonnet, read-only)
```
subagent_type: general-purpose
model: sonnet
```
**Prompt**:
> You are assembling a structured evidence dossier for a thesis literature review rewrite.
>
> Read ALL files in `thesis/references/literature_analysis/paper_extractions/*.json` (12 files), the concept graph at `thesis/references/literature_analysis/concept_graph.json`, and the mechanism extraction at `thesis/references/literature_analysis/mechanism_extraction.json`.
>
> Produce TWO JSON files in `thesis/chapters/.litreview_workspace/`:
>
> **dossier.json** — Organize ALL extracted evidence by the target section structure:
> ```json
> {
> "2.1.1_task_framework": {
> "papers": ["autor_levy_murnane_2003"],
> "key_quotes": [{"text": "...", "page": N, "bibkey": "autor2003skill"}],
> "claims": [{"claim": "...", "evidence": "...", "strength": "strong"}],
> "concept_edges": ["task_model → routine_manual", "task_model → substitution"],
> "constructs": [{"name": "...", "definition": "..."}]
> },
> "2.1.2_polarization": { ... },
> ...
> }
> ```
>
> **gaps.json** — Identify areas where extractions are thin and RAG queries would help:
> ```json
> {
> "gaps": [
> {
> "section": "2.1.3",
> "topic": "rent dissipation mechanism details",
> "query": "rent dissipation automation wage premium loss",
> "reason": "Extraction has claim but no detailed mechanism quote"
> },
> ...
> ]
> }
> ```
>
> Map evidence to these sections:
> - 2.1.1: autor_levy_murnane_2003 (task framework, DOT, routine/nonroutine)
> - 2.1.2: autor_dorn_2013 (polarization, U-shape, commuting zones, shift-share)
> - 2.1.3: acemoglu_restrepo_2025 (task displacement, labor share, rent dissipation)
> - 2.2.1: autor_dorn_hanson_majlesi_2020, colantone_stanig_2018 (China shock politics)
> - 2.2.2: frey_berger_chen_2018, anelli_colantone_stanig_2019 (robots and voting)
> - 2.2.3: methodological parallels (shift-share across studies, pseudo-panel)
> - 2.3.1: economic insecurity evidence (Colantone & Stanig, Norris/Inglehart)
> - 2.3.2: inglehart_norris_2016, norris_inglehart_2018 (cultural backlash)
> - 2.3.3: mutz_2018, morgan_2018 (status threat debate)
> - 2.3.4: osborne_2023, stenner_2005 (psychological mechanisms, dual-process)
> - 2.3.5: manunta_2025, gidron_hall_2017 (identity threat integration)
> - 2.4: contribution positioning
>
> Include ALL verbatim quotes with page numbers. Be exhaustive — this is the evidence base for the entire chapter.
### Agent 2: RAG Deepener (sonnet, Bash access)
```
subagent_type: general-purpose
model: sonnet
```
**Prompt**:
> You supplement the literature dossier with additional evidence from the thesis RAG corpus (105 papers, 10,217 chunks in ChromaDB).
>
> First, if `thesis/chapters/.litreview_workspace/gaps.json` exists, read it and use those queries. If not yet available, use the default queries below.
>
> For each query, run:
> ```bash
> cd /Users/alessandro/Projects/Tesi/thesis/references/RAG && source venv/bin/activate && python /Users/alessandro/Projects/Tesi/.claude/skills/verify-claims/scripts/query_rag.py "QUERY" --top-k 5 --json
> ```
>
> Run 20-30 queries targeting these underdeveloped topics:
>
> **Section 2.1 (Automation & Labor)**:
> 1. "task is routine if can be accomplished by machines following explicit programmed rules"
> 2. "Dictionary of Occupational Titles DOT task measures"
> 3. "labor market polarization U-shape employment"
> 4. "commuting zone shift-share Bartik instrument"
> 5. "task displacement labor share decline automation"
> 6. "rent dissipation wage premium automation"
> 7. "between-group inequality automation 52 percent"
>
> **Section 2.2 (Shocks & Politics)**:
> 8. "China import shock political polarization electoral consequences"
> 9. "trade exposure radical right nationalist party Europe"
> 10. "economic nationalism protectionism import competition"
> 11. "robot exposure Trump presidential election swing states"
> 12. "counterfactual occupation assignment automation voting"
> 13. "robot exposure distinct from trade exposure"
>
> **Section 2.3 (Mechanisms)**:
> 14. "economic insecurity hypothesis pocketbook egotropic sociotropic"
> 15. "cultural backlash silent revolution post-materialist values"
> 16. "status threat group dominance racial resentment"
> 17. "Morgan critique Mutz 51 vote switchers fixed effects"
> 18. "dual-process model RWA SDO authoritarianism"
> 19. "authoritarian dynamic normative threat activation"
> 20. "identity threat mediates economic cultural populism"
> 21. "subjective social status populist right"
> 22. "dangerous world belief right-wing authoritarianism"
> 23. "competitive jungle social dominance orientation"
>
> **Section 2.4 (Contribution)**:
> 24. "pseudo-panel repeated cross-section Deaton synthetic cohort"
> 25. "IRT ideology estimate ideal point continuous measure"
>
> Save results to `thesis/chapters/.litreview_workspace/rag_supplements.json`:
> ```json
> {
> "queries": [
> {
> "query": "...",
> "target_section": "2.1.1",
> "results": [
> {"source": "Author (Year)", "page": N, "text": "...", "similarity": 0.85}
> ]
> }
> ]
> }
> ```
>
> Prioritize results with similarity > 0.70 that contain verbatim-quotable text with specific numbers, definitions, or methodological details.
**Wait for both agents to complete before proceeding to Phase 2.**
---
## PHASE 2: ARCHITECTURE (single agent)
### Agent 3: Narrative Architect (opus)
```
subagent_type: general-purpose
model: opus
```
**Prompt**:
> You are designing the narrative architecture for a thesis literature review chapter. You have access to:
>
> 1. Evidence dossier: `thesis/chapters/.litreview_workspace/dossier.json`
> 2. RAG supplements: `thesis/chapters/.litreview_workspace/rag_supplements.json`
> 3. Current Ch.2: `thesis/chapters/02_literature.tex` (the version being replaced)
> 4. Literature synthesis: `thesis/references/literature_analysis/literature_synthesis.md`
> 5. Chapter openings for forward refs:
> - `thesis/chapters/03_data.tex` (first 30 lines)
> - `thesis/chapters/04_methodology.tex` (first 30 lines)
> - `thesis/chapters/05_results.tex` (first 30 lines)
>
> Read all of these files. Then produce `thesis/chapters/.litreview_workspace/outline.md` with this structure:
>
> ```markdown
> # Chapter 2 Outline: Literature Review
>
> ## Introductory Paragraph
> - Preview all four sections using \Cref{sec:lit_automation}, etc.
> - ~8-10 lines
>
> ## Section 2.1: Automation and the Labor Market
> \label{sec:lit_automation}
> Estimated: ~100-120 lines
>
> ### 2.1.1 The Task-Based Framework \label{subsec:task_model}
> - ~25-30 lines
> - Topic sentence: [exact sentence]
> - Paper ordering: ALM 2003 only
> - Key quotes to include: [list with page numbers]
> - Concepts to define: routine vs nonroutine, DOT operationalization, substitution/complementarity
> - Forward ref: \Cref{ch:data} (O*NET as modern DOT successor)
> - Transition to 2.1.2: [sentence bridging to polarization]
>
> ### 2.1.2 Labor Market Polarization \label{subsec:polarization}
> [same structure...]
>
> [continue for ALL subsections...]
>
> ## Citation Plan
> | BibTeX key | Sections used | Role (primary/supporting) |
>
> ## Forward Reference Map
> | \Cref target | Section where introduced | Context |
>
> ## Estimated Total: ~420 lines
> ```
>
> **Critical requirements**:
> - Every subsection must have a specific topic sentence drafted
> - Every transition between subsections must be planned
> - Every direct quote must be assigned to a specific location with page citation
> - The outline must specify which concept graph edges inform each transition
> - Section 2.2.3 (Methodological Parallels) is NEW — design it to bridge empirics → your methodology
> - Section 2.3.5 (Identity Threat as Integrating Framework) is NEW — must synthesize the mechanisms debate
> - Section 2.4 must connect to ALL of Ch.3, Ch.4, Ch.5
>
> **DISCURSIVE POSITIONING requirement**:
> The literature review must read as a CONVERSATION with other researchers, not a catalog of findings.
> For each subsection, the outline must plan at least one "positioning passage" that follows this pattern
> (common in top economics journals like QJE, AER, JEPS):
>
> **Pattern A — "Closely related / distinct from"**: Name 2-3 closest papers → describe what they do
> → pivot with "distinct from" / "I depart from" / "unlike" → explain your approach.
> Example from Autor et al. (2024, QJE): "Our work is closely related to Webb (2020) and Kogan et al. (2021),
> who use NLP tools to identify innovations... Distinct from this literature, we develop a method to..."
>
> **Pattern B — "While X... I instead..."**: Compare a specific methodological choice by naming what others did
> and explaining your alternative.
> Example: "While Frey et al. (2018) aggregate robot exposure at the commuting-zone level, and
> Anelli et al. (2019) exploit individual-level variation through counterfactual occupation assignment,
> I adopt a group-level pseudo-panel..."
>
> **Pattern C — "Building on X, but extending..."**: Acknowledge what you inherit and add.
> Example: "Following the shift-share logic of Autor & Dorn (2013), I aggregate industry-level shocks
> to demographic groups using base-year employment weights—but unlike their fixed-baseline approach,
> I use rolling windows that capture recent automation dynamics."
>
> **Pattern D — "None of these studies... This is the gap"**: After reviewing 3-4 related papers,
> identify what is missing that your thesis addresses.
>
> The outline must explicitly mark WHERE each positioning passage goes, using tags like:
> `[POSITION: Pattern B — compare Frey CZ-level vs Anelli individual vs my group-level]`
>
> Key comparisons to plan (at minimum):
> - Automation measure: robot counts (A-R 2020) vs RTI proxies (Autor-Dorn) vs task displacement (A-R 2025) → yours
> - Unit of analysis: commuting zones (ADH, Frey) vs individual (Anelli) vs demographic groups (yours)
> - Political outcome: vote share (Frey, ADHM) vs party ID vs IRT ideology (yours)
> - Identification: county-level shift-share (Frey) vs individual counterfactual (Anelli) vs group-level TWFE (yours)
> - Geography: US only (Mutz, Frey, ADHM) vs Europe (Colantone-Stanig, Anelli) vs your US state-level
> - Temporal design: cross-section (Inglehart-Norris) vs panel (Mutz, Morgan) vs pseudo-panel (yours)
>
> Write in the voice of a Bocconi Master's student: precise, measured, first person singular.
**Wait for completion before Phase 3.**
---
## PHASE 3: DRAFTING (4 parallel agents)
Launch FOUR section-drafter agents in parallel using the Task tool. Each writes one `.tex` file.
### Agent 4a-4d: Section Drafters (opus, 4 instances)
For each section (2.1, 2.2, 2.3, 2.4), use:
```
subagent_type: general-purpose
model: opus
```
**Prompt template** (adjust section number, label, and line target):
> You are drafting Section 2.X of the Literature Review chapter for a Bocconi Master's thesis.
>
> Read these files:
> 1. Your section in the outline: `thesis/chapters/.litreview_workspace/outline.md` (Section 2.X only)
> 2. Evidence for your section from: `thesis/chapters/.litreview_workspace/dossier.json` (keys starting with "2.X.")
> 3. RAG supplements: `thesis/chapters/.litreview_workspace/rag_supplements.json` (entries targeting "2.X.*")
> 4. BibTeX file: `thesis/references.bib` (to verify all keys exist)
> 5. Notation registry: `.claude/rules/notation-registry.md`
> 6. Citation standards: `.claude/rules/literature-citations.md`
> 7. Forward reference requirements: `.claude/rules/forward-references.md`
>
> Write `thesis/chapters/.litreview_workspace/drafts/sec_2.X.tex` containing ONLY the LaTeX content for this section (no `\chapter`, no preamble).
>
> **Requirements**:
> - First person singular: "I review", "I examine", "I identify"
> - Present tense for methodology descriptions, past tense for data/findings
> - Use `\citet{key}` for author-as-subject, `\citep{key}` for parenthetical
> - Every direct quote in `` ``...'' `` must have `\citep[p.~N]{key}`
Auf GitHub ansehen