$npx -y skills add dleerdefi/claude-code-construction --skill viewport-highlighterIdentify and highlight viewports on construction drawing sheets using vision. Detects view boundaries, titles, scales, and view types. Creates viewport overlays via AgentCM API. Requires AgentCM (.construction/ directory). Triggers: 'highlight viewports', 'find views'.
| 1 | # Viewport Highlighter |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Automate viewport segmentation of construction drawing sheets. Each sheet |
| 6 | typically contains 1-12+ distinct views (floor plans, sections, elevations, |
| 7 | details, schedules). This skill identifies all views, determines their |
| 8 | boundaries, extracts metadata (title, detail number, scale, type), and |
| 9 | creates viewport highlights — producing the same result as a user manually |
| 10 | drawing and labeling each viewport in the UI. |
| 11 | |
| 12 | Does NOT: modify existing viewports, delete viewports, or change element |
| 13 | data. Only creates new viewport highlights and populates their metadata. |
| 14 | |
| 15 | --- |
| 16 | |
| 17 | ## Step 0: Verify AgentCM Mode |
| 18 | |
| 19 | This skill **requires AgentCM**. It writes viewport overlays through the AgentCM REST API and has no standalone output path. |
| 20 | |
| 21 | **Check for `.construction/` directory at the project root.** |
| 22 | |
| 23 | If `.construction/` is absent, **stop immediately** and tell the user: |
| 24 | > "viewport-highlighter requires an AgentCM project — `.construction/` directory not found. This skill submits viewport overlays through the AgentCM API and cannot operate without it. Open this project in AgentCM first, then re-run." |
| 25 | |
| 26 | If `.construction/` exists: |
| 27 | - Read `.construction/CLAUDE.md` for project context |
| 28 | - Read `.construction/database.yaml` for `query_command`, `project_id`, `api_url` |
| 29 | - Read `.construction/index/sheet_index.yaml` for sheet inventory |
| 30 | - Sheet images at `.construction/rasters/{sheet_number}.png` |
| 31 | - OCR data queryable via `extracted_items` table in PostgreSQL |
| 32 | - Write viewports via REST API |
| 33 | |
| 34 | ## Step 1: User Scopes the Task |
| 35 | |
| 36 | User provides sheet scope: |
| 37 | - Specific sheets: "A2.01, A2.02, A5.01" |
| 38 | - By discipline: "all architectural sheets" |
| 39 | - All sheets: "every sheet in the set" |
| 40 | |
| 41 | Optional: user can specify which view types to look for (e.g., "only floor |
| 42 | plans and sections"). Default: identify ALL views on each sheet. |
| 43 | |
| 44 | **Before proceeding:** Confirm the sheet list and any filters with the user. |
| 45 | Show the count of sheets to process. |
| 46 | |
| 47 | ## Step 2: Vision — Identify View Boundaries |
| 48 | |
| 49 | For each sheet in scope, rasterize to PNG (if not already available) and |
| 50 | examine with vision. |
| 51 | |
| 52 | ```bash |
| 53 | # Rasterize on demand if the pre-rendered PNG is missing |
| 54 | ${CLAUDE_SKILL_DIR}/../../bin/construction-python \ |
| 55 | ${CLAUDE_SKILL_DIR}/../../scripts/pdf/rasterize_page.py \ |
| 56 | "{pdf_path}" {page_index} --dpi 200 --output /tmp/{sheet_number}.png |
| 57 | ``` |
| 58 | |
| 59 | **Vision task:** Examine the full sheet image. Identify every distinct view |
| 60 | (drawing area) on the sheet. For each view, extract: |
| 61 | |
| 62 | | Field | What to look for | Example | |
| 63 | |-------|-----------------|---------| |
| 64 | | **Title** | View title bar text (usually centered below the view) | "FIRST FLOOR PLAN" | |
| 65 | | **Detail Number** | Number in the detail bubble or title bar | "1", "A2.01", "3/A5" | |
| 66 | | **Scale** | Scale annotation near the title bar | `1/8" = 1'-0"`, `1/4" = 1'-0"`, "NTS" | |
| 67 | | **View Type** | Classification of the drawing content | plan, section, elevation, detail, schedule | |
| 68 | | **Bounding Region** | Approximate rectangle enclosing the entire view (normalized 0-1) | `{x: 0.02, y: 0.05, w: 0.48, h: 0.65}` | |
| 69 | |
| 70 | ### View boundary detection signals |
| 71 | |
| 72 | Use these visual cues to determine where one view ends and another begins: |
| 73 | |
| 74 | 1. **Heavy border lines** — thick lines separating drawing areas |
| 75 | 2. **Title bars** — horizontal bars with view name, scale, detail number |
| 76 | 3. **Detail bubbles** — circles or hexagons with detail/sheet reference |
| 77 | 4. **Whitespace gaps** — clear separations between drawing content |
| 78 | 5. **Grid systems** — column/row grids define the extents of a plan view |
| 79 | 6. **Section cut lines** — long dash-dot lines with directional arrows |
| 80 | 7. **Match lines** — indicate where a plan continues on another sheet |
| 81 | |
| 82 | ### View type classification |
| 83 | |
| 84 | | View Type | `extractionScope` value | Signals | |
| 85 | |-----------|------------------------|---------| |
| 86 | | Floor plan | `plan` | Grid lines, room names/numbers, dimension strings, north arrow | |
| 87 | | Enlarged plan | `plan` | "ENLARGED" in title, larger scale than base plan, room detail | |
| 88 | | Section | `section` | Section cut reference (e.g., "SECTION A-A"), vertical layers, material hatching | |
| 89 | | Elevation | `elevation` | "ELEVATION" in title, facade view, material callouts, floor lines | |
| 90 | | Detail | `detail` | Detail bubble reference, large scale (3"=1'-0"), construction assembly closeup | |
| 91 | | Schedule | `schedule` | Tabular grid, column headers, row data (door schedule, finish schedule) | |
| 92 | | Diagram | `other` | Riser diagrams, single-line diagrams, flow diagrams | |
| 93 | |
| 94 | ### Bounding region estimation from vision |
| 95 | |
| 96 | When estimating the bounding region as normalized 0-1 coordinates: |
| 97 | |
| 98 | - **x** = left edge of view content / sheet width (0.0 = left edge) |
| 99 | - **y** = top edge of view conte |