$npx -y skills add dleerdefi/claude-code-construction --skill subcontract-writerGenerate a complete subcontract from a firm's template, awarded bid, and project specs. Outputs a Word document. Triggers: 'subcontract', 'sub agreement', 'write contract', 'draft subcontract'. Requires awarded bid.
| 1 | # Subcontract Writer |
| 2 | |
| 3 | Generates a complete, execution-ready subcontract agreement from a firm's template, the awarded bid, and project specifications. **You are the intelligence layer** — you read every document, extract all data, generate every article's text, make legal/commercial judgments, and write fully-populated JSON files. The Python formatter is a thin rendering utility that makes no content decisions. |
| 4 | |
| 5 | **Output:** Word document (.docx) matching the firm's template structure. |
| 6 | |
| 7 | **Dependency:** Requires `python-docx` in the construction Python environment. |
| 8 | |
| 9 | **Key principle:** The bid document is the PRIMARY input. It establishes what was priced, at what rates, with what inclusions and exclusions. Specifications inform scope descriptions and technical requirements. The template provides article structure and standard boilerplate. |
| 10 | |
| 11 | --- |
| 12 | |
| 13 | ## Pipeline Position |
| 14 | This skill can be invoked directly when the user has an awarded bid and wants to generate a subcontract, or as the final step of the bid pipeline: |
| 15 | ``` |
| 16 | /bid-tabulator → /bid-evaluator → user confirms → THIS SKILL |
| 17 | ``` |
| 18 | Either way, the awarded bid document (Slot B) is the mandatory input. |
| 19 | |
| 20 | ## Mode Detection |
| 21 | Check for `.construction/` directory at the project root. |
| 22 | - **AgentCM mode**: Read specs from `.construction/spec_text/{section}.txt`. Use sheet index from `.construction/index/sheet_index.yaml` for drawing references. Read project metadata from `.construction/CLAUDE.md`. |
| 23 | - **Flat File mode**: Discover spec PDFs via project `CLAUDE.md` paths or directory search. Read drawing sheets directly from PDF. |
| 24 | |
| 25 | --- |
| 26 | |
| 27 | ## Architecture: Five Phases in Order |
| 28 | |
| 29 | Execute in five sequential phases. Each phase has a defined output that must be completed before the next begins. **Do not skip phases or combine them.** The most common failure mode is attempting Phase 4 (writing) before Phase 3 (validation) is complete. |
| 30 | |
| 31 | ``` |
| 32 | Subcontract Writer Progress: |
| 33 | Phase 1 → Phase 2 → Phase 3 → USER CHECKPOINT → Phase 4 → Phase 5 |
| 34 | Triage Extract Validate Confirm data Write Verify |
| 35 | ``` |
| 36 | |
| 37 | --- |
| 38 | |
| 39 | ## Phase 1 — Document Triage and Slot Assignment |
| 40 | |
| 41 | Before reading any document substantively, assign each uploaded file to its slot. State the assignments to the user before proceeding. |
| 42 | |
| 43 | | Slot | Role | Source | What It Provides | |
| 44 | |------|------|--------|-----------------| |
| 45 | | A | Template | Subcontract PDF/DOCX | Article structure, boilerplate language, required sections | |
| 46 | | B | Awarded bid | Subcontractor bid PDF | **Contract sum, quantities, unit rates, inclusions, exclusions, VE alternates** | |
| 47 | | C | Specifications | Spec section PDFs | Scope descriptions, submittal requirements, warranty clauses, installer qualifications | |
| 48 | | D | Drawings | Finish schedule, floor plans | Room codes, area takeoffs, scope boundaries | |
| 49 | |
| 50 | **Slot B is mandatory.** If missing, stop and output: |
| 51 | ``` |
| 52 | I need the awarded subcontractor's bid document before I can generate this |
| 53 | subcontract. The bid is the source of truth for the contract sum, quantities, |
| 54 | and unit rates. Which file is the awarded bid? |
| 55 | ``` |
| 56 | |
| 57 | Read Slot A first to understand the required article structure. Note every article heading. Flag any article that requires project-specific content (not just boilerplate) — these become required extraction targets in Phase 2. |
| 58 | |
| 59 | If no template is provided, ask: "Do you have a standard subcontract template?" If none available, use AIA A401-style structure as fallback. |
| 60 | |
| 61 | --- |
| 62 | |
| 63 | ## Phase 2 — Structured Extraction, One Slot at a Time |
| 64 | |
| 65 | Run a separate extraction pass for each slot. Write extracted data to `scope_data.json` incrementally. Do not combine slots in a single read. |
| 66 | |
| 67 | ### Slot B Extraction (Bid Document) — Run First |
| 68 | |
| 69 | Read the bid PDF using vision. Extract every field below. Mark any field not found as `MISSING` — do not infer or estimate. |
| 70 | |
| 71 | **Commercial data:** |
| 72 | - Subcontractor company name (exact legal name from letterhead) |
| 73 | - Address, phone, email |
| 74 | - License/registration number |
| 75 | - Estimator/contact name |
| 76 | - Proposal number and date |
| 77 | - Bid validity period (if stated) |
| 78 | - Total contract sum (exact dollar amount) |
| 79 | |
| 80 | **Scope data:** |
| 81 | - Line items with: spec section, description, quantity, unit, unit rate, extended amount |
| 82 | - Inclusions list (verbatim from bid) |
| 83 | - Exclusions list (verbatim from bid — critical for scope gap prevention) |
| 84 | - Value engineering alternates with VE ID, description, and deduct amount |
| 85 | - Qualifications or clarifications |
| 86 | |
| 87 | **Verify:** Line item amounts must sum to the total contract sum. If they don't, flag the discrepancy. |
| 88 | |
| 89 | ### Slot A Extraction (Template) |
| 90 | |
| 91 | **If .docx template:** Use python-docx to read headings, paragraphs, and identify article structure. |
| 92 | |
| 93 | **If PDF |