# Prompt 3b — Write the codebook as an Excel workbook

## Context
We have agreed the typologies in the Step 3a memo, with my edits marked in `typologies_reviewed.md` (Prompt 3c records those edits). Now formalise them as a codebook that both a human coder and an AI coder can follow without asking questions.

## Task
Write `codebook_<project>_v2.xlsx` with these sheets:

- **README** — title, version and date, unit of analysis, research question, list of sheets.
- **Variables** — one row per variable: name, label, type (binary / categorical / ordinal / text), definition, allowed values.
- **One sheet per categorical variable** — columns `code`, `label`, `code_when` (the rule), with the residual category last.
- **Decision_Rules** — the numbered cross-variable rules, one per row.
- **Dropdown_Values** — one column per categorical variable listing its codes, so Excel data validation can be built from it.
- **Coding_Template** — a header row only: `doc_id, instance_id, article_date, article_long_title, article_url, relevance, enterprise_name, sector, event_type, leader_visit, province, evidence_text, coder_confidence, notes`.

Rules for writing it:
- Every category rule must be decidable from the article text plus the enterprise name; say explicitly when background knowledge is allowed (for example province).
- Define `instance_id` as `<doc_id>-<n>`, numbering enterprises in order of appearance.
- Define `evidence_text` as a verbatim excerpt of one or two sentences; no paraphrase.
- Define `coder_confidence` as 3 / 2 / 1 with a rule for each level.
- Keep every rule to one or two sentences. No examples longer than a title.

Also write the same content to `codebook.json` so the extraction prompt can read it programmatically.

## Output
The two files, then a short list of the places where you had to choose between two reasonable rules, so I can confirm or overrule each.
