$npx -y skills add dleerdefi/claude-code-construction --skill tag-audit-and-takeoffCount-based quantity takeoff and tag completeness auditing for construction drawings. Vision + OCR reconciliation, sheet markup, Excel QTO output. Triggers: 'tag audit', 'quantity takeoff', 'QTO', 'count fixtures'.
| 1 | # Tag Audit & Quantity Takeoff |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Count-based QTO for tagged construction elements — fixtures, devices, |
| 6 | doors, equipment, and any element identified by a tag/symbol on drawings. |
| 7 | Does NOT do area (sqft) or linear (lf) takeoffs — only discrete counts. |
| 8 | |
| 9 | The QTO is a byproduct of the audit. The real value: the completeness |
| 10 | engine that finds what's tagged, what's missing, and produces a defensible |
| 11 | count with full provenance for every number. |
| 12 | |
| 13 | Does NOT: do area/linear takeoffs, create outbound documents autonomously, |
| 14 | override user-approved groupings, or assume quantities without provenance. |
| 15 | |
| 16 | --- |
| 17 | |
| 18 | ## Step 0: Detect Operating Mode |
| 19 | |
| 20 | Check for `.construction/` directory at the project root. |
| 21 | |
| 22 | **AgentCM mode** (`.construction/` exists): |
| 23 | - Read `.construction/CLAUDE.md` for project context |
| 24 | - Read `.construction/database.yaml` for `query_command` and `project_id` |
| 25 | - Sheet images at `.construction/rasters/{sheet_number}.png` |
| 26 | |
| 27 | **Verify raster images exist:** Check `.construction/rasters/` for PNG files. |
| 28 | If empty, tell the user: "Raster images not found. Open this project in |
| 29 | AgentCM to trigger the export, or run: |
| 30 | `curl -s -X POST '{api_url}/projects/{project_id}/graph/export' -H 'Content-Type: application/json' -d '{\"rootPath\": \"'$(pwd)'\"}'`" |
| 31 | You can also rasterize individual sheets on demand using the rasterize_page.py script. |
| 32 | - OCR data queryable via `extracted_items` table in PostgreSQL |
| 33 | - Write results back via API: `POST /api/projects/{id}/tag-detections/ingest` |
| 34 | |
| 35 | **Flat File mode** (no `.construction/`): |
| 36 | - Discover sheet images from CLAUDE.md or user-provided paths |
| 37 | - Vision-only pipeline (Steps 2-3 skipped) |
| 38 | - Write marked-up PNGs and QTO JSON to project directory |
| 39 | |
| 40 | ## Step 1: User Scopes the Task |
| 41 | |
| 42 | User provides: (1) tag type — e.g., "plumbing fixtures", "doors", |
| 43 | "light fixtures" (see `references/tag-types.md` for full list), and |
| 44 | (2) sheet scope — specific sheets, a discipline, or "all sheets". |
| 45 | Confirm scope before proceeding. |
| 46 | |
| 47 | **Custom tag types:** If the user requests a tag type not in |
| 48 | `references/tag-types.md` (e.g., "keynote legends", "fire dampers", |
| 49 | "seismic bracing"), treat it as a custom type. Use it in the `tag_type` |
| 50 | field at ingest — the server auto-registers unknown types in the |
| 51 | `tag_types` table with default styling. The normalized name will be |
| 52 | `qto_{type}` (e.g., `qto_keynote_legend`). Custom types appear in the |
| 53 | Group Review gallery and support the full accept/reject/promote workflow. |
| 54 | |
| 55 | **REQUIRED: Tag type resolution.** Before using any `tag_type` value, |
| 56 | you MUST resolve it against existing types: |
| 57 | |
| 58 | 1. Query `GET /api/projects/{id}/group-review/available-types` to see |
| 59 | all active tag types for this project |
| 60 | 2. Check if the user's requested type matches ANY existing type name |
| 61 | 3. Apply alias resolution — these names are synonyms of existing types: |
| 62 | - `detail_callout`, `section_callout`, `interior_elevation`, |
| 63 | `callout_single_ref`, `single_ref_callout` → `simple_callout` |
| 64 | - `multi_callout`, `callout_multi_ref`, `multi_ref_callout` |
| 65 | → `multi_detail_callout` |
| 66 | 4. If the resolved type exists in available-types, USE THAT NAME |
| 67 | 5. Report to user: "Resolved type: '{resolved_name}' (matched from |
| 68 | '{user_input}')" — get confirmation before proceeding |
| 69 | 6. **If there is ANY ambiguity** about whether a requested tag type |
| 70 | maps to an existing type, **ASK THE USER** before proceeding. |
| 71 | Do not guess or invent a new type name. |
| 72 | 7. Only auto-register a truly new type if no existing type or alias |
| 73 | matches after checking both the available-types list and the alias |
| 74 | map above |
| 75 | |
| 76 | NEVER invent a new type name for concepts that already have canonical |
| 77 | types. When in doubt, ask. |
| 78 | |
| 79 | ## Step 1.5: Check Existing Coverage [REQUIRED GATE] (AgentCM mode only) |
| 80 | |
| 81 | **HARD GATE — you MUST complete this step before proceeding to Step 2.** |
| 82 | Do not skip this step. If the API is unreachable, stop and tell the user. |
| 83 | |
| 84 | Before scanning sheets, query what's already tagged per sheet: |
| 85 | |
| 86 | ```bash |
| 87 | curl -s "http://localhost:3001/api/projects/{project_id}/sheets/{sheet_id}/claimed-elements" |
| 88 | ``` |
| 89 | |
| 90 | Response: |
| 91 | ```json |
| 92 | { |
| 93 | "claimed_element_ids": ["el_001", "el_002", ...], |
| 94 | "suggestion_count": 12, |
| 95 | "by_type": { "qto_room_tag": 8, "room_tag": 4 }, |
| 96 | "existing_tags": [ |
| 97 | { "id": "...", "proposedType": "qto_room_tag", "proposedText": "KITCHEN", |
| 98 | "status": "accepted", "constituentIds": [...], "combinedBbox": {...}, "confidence": 0.92 } |
| 99 | ] |
| 100 | } |
| 101 | ``` |
| 102 | |
| 103 | Report to user: "Sheet A-1.4: 12 tags already detected (8 accepted, 4 pending)." |
| 104 | |
| 105 | **Reconciliation rules:** |
| 106 | - **EXCLUDE** claimed element IDs from spatial queries (Steps 3-4) — |
| 107 | add `AND id NOT IN ('{id1}', '{id2}', ...)` to SQL WHERE clauses |
| 108 | - **INCLUDE** `existing_tags` in the final QTO output — the |