zhc-closeout
Delivers the full ZeroHumanWorkforce closeout experience — KIE.ai infographics, Veo celebration video, 9-section Notion page tree, 7-message Telegram sequence, Command Center fire, and n8n wire-up. Ev
Files70
View on GitHubSKILL.md37-zhc-closeout/SKILL.md
GitHubSkill 37: ZHC Closeout
MANDATORY - Teach Yourself Protocol (TYP)
Before using this skill, complete the Teach Yourself Protocol (Skill 01) on this folder.
Required read order:
- SKILL.md (this file)
- QUALITY-GATE.md - the MANDATORY 8.5 rate + QC gate every deliverable must pass
- INSTRUCTIONS.md — runtime execution guide + state machine + 6-step pipeline
- INSTALL.md — one-time setup steps (KIE_API_KEY, NOTION_API_TOKEN, budget caps)
- CORE_UPDATES.md — what gets appended to AGENTS.md
- CHANGELOG.md — change history
Per N3 ("read before act"), do not skip. Per N4, follow steps in declared order.
MANDATORY: The 8.5 Quality Gate
Rate + QC EVERY closeout deliverable; do not deliver below 8.5; iterate until it passes. See QUALITY-GATE.md.
This is a systemic, non-optional requirement from Trevor. No closeout artifact (workforce org chart, how-work-flows diagram, Notion closeout docs) may be delivered to a client until the running agent has RATED it 1-10 against the rubric in QUALITY-GATE.md and it scores at least 8.5 AND passes its QC checks. If an artifact scores below 8.5, the agent MUST iterate/regenerate (edit the HTML/CSS for the org chart, re-prompt or switch model for the AI flow image, rewrite for docs) and re-rate until it reaches 8.5 or higher, THEN deliver. If it still cannot pass after the max attempts, HOLD the artifact (do not deliver it) and flag for human review. The org-chart rubric's #1 requirement is a TRUE reporting tree with visible connector lines (Owner -> CEO -> clusters -> departments), not a grid of cards. Below 8.5 is never shipped.
What This Skill Is About
Skill 37 is the closeout layer for the AI Workforce build pipeline. It is what actually CLOSES THE LOOP with the client after Skill 23 (AI Workforce Blueprint) finishes building their zero-human workforce.
Before v10.14.17, the pipeline had no enforced closeout:
- Skill 23 finished writing department folders, flipped
buildCompletedAt— and that was it. - Skill 32 (Command Center) was "supposed" to fire next via documentation alone, but documentation is not enforcement.
- The owner often heard nothing. No celebration. No infographics. No closeout doc. No Command Center URL. No nothing.
Skill 37 fixes that by making the closeout STATE-MACHINE-DRIVEN, just like the build-resume layer fixed the build-interruption gap in v10.14.16.
How Skill 37 Fits In the Pipeline
Owner says "build my company"
│
▼
Skill 23 interview (Katie Couric / Oprah persona) ──────► workforce-interview-answers.md
│
▼
Skill 23 build (departments + roles) ─────────────────► .workforce-build-state.json
│ (every department: pending → building → done)
│ (final dept done → buildCompletedAt set)
▼
🆕 Skill 37 ZHC Closeout (THIS SKILL) ─────────────────► closeoutStatus: pending → generating → sent → done
│
├── Step 1: Run Skill 32 (Command Center) ────────► commandCenterUrl captured
├── Step 2: Generate Infographic #1 (Structure) ──► infographic1Url captured
├── Step 3: Generate Infographic #2 (Workflow) ───► infographic2Url captured
├── Step 4: Generate Celebration Video ───────────► celebrationVideoUrl captured
├── Step 5: Build Notion Page Tree (9 sections) ──► notionRootPageUrl captured
└── Step 6: Telegram Delivery (7-message sequence)► closeoutCompletedAt set
The resume cron (Skill 23's scripts/resume-workforce-build.sh) is extended in v10.14.17 to also fire whenever buildCompletedAt is set but closeoutStatus != "done" && closeoutStatus != "sent". So if the closeout dies mid-way, the cron wakes the agent back up to finish it — same mechanism, same lockfile, same attempt cap.
When This Skill Triggers
Automatic, not manual. The trigger is the state file, not a user instruction.
Specifically, this skill fires when:
.workforce-build-state.jsonhasbuildCompletedAt != nullANDcloseoutStatus == "pending"(initial state set by Skill 23's master orchestrator) ORcloseoutStatus == "generating"(closeout was interrupted mid-step)
The agent gets invoked either:
- Inline at end of Skill 23 build (master orchestrator calls Skill 37 directly), or
- Via the resume cron self-pinging when state goes dirty.
What Gets Delivered to the Client
By the end of Skill 37 execution, the client has received all of the following via Telegram, in order, paced (not spam-blasted):
| # | Message | Source |
|---|---|---|
| 1 | "🎉 Your zero-human company is built!" + summary stats | Composed from state file |
| 2 | Workforce Structure infographic (Telegram sendPhoto) | HTML + Playwright Chromium screenshot (local, deterministic text) |
| 3 | How Work Flows infographic (Telegram sendPhoto) | KIE.AI GPT Image 2.6 sunburst (gpt-image-2-6/sunburst-text-to-image; fallback nano-banana-2) |
| 4 | 4–8 sec celebration video (Telegram sendVideo, bytes uploaded) | KIE.AI Gemini Omni Video (fallback: Veo 3.1) |
| 5 | "Your full Notion closeout doc → [link]" | Notion API |
| 6 | "Your BlackCEO Command Center → [URL]" | Skill 32 output |
Plus the Notion page tree itself (9 top-level sections + nested department/role pages).
The Notion Page Tree Spec
Created in the client's own Notion workspace using their NOTION_API_TOKEN (already in their container env).
📕 Your Zero-Human Company — [Company Name]
├── 1. What Is a Zero-Human Company?
│ • Positive framing — what it IS and is NOT
│ • Not "no humans" — it's "humans freed from execution"
│ • Owner-led, AI-executed
├── 2. What Is a Zero-Human Workforce?
│ • People-equivalent framing
│ • Departments as teams, agents as employees
│ • Why this matters for delegation
├── 3. Your Workforce Structure
│ • Embed Infographic #1 (Workforce Structure org chart)
│ • Owner → CEO agent → Dept Heads → AI Employees
│ • Lists each department + role count
├── 4. How Your Workforce Runs
│ • Embed Infographic #2 (How Work Flows diagram)
│ • Task in → CEO routes → Dept Head dispatches → output
│ • Real example walkthrough
├── 5. Departments & Roles
│ └── (one sub-page per department)
│ • Department name + purpose
│ • List of roles in this department:
│ - Name
│ - What they do
│ - Purpose
│ - Ideal use cases (3-5)
│ - Trigger phrases
├── 6. Communication Hierarchy
│ • Owner → CEO → Dept Heads → AI Employees
│ • Dept Heads spawn temporary sub-agents to get jobs done
│ • Why you talk to the CEO, not the employees, by default
├── 7. Six Sigma in Your ZHC
│ • DMAIC framework (Define / Measure / Analyze / Improve / Control)
│ • How DMAIC applies to YOUR specific departments
│ • Per-department DMAIC snapshot
├── 8. Book-to-Persona System
│ • Separate sub-page
│ • How book-to-persona governs every task
│ • The decision matrix scoring criteria (Relevance / Authority / Recency / Depth / Fit)
└── 9. Your First 7 Days
• Day-by-day action checklist for week 1
• What to delegate first
• What to NOT touch yet
• When/how to give the CEO feedback
The templates/notion-page-tree.json file defines this structure programmatically. Placeholders ({{COMPANY_NAME}}, {{DEPARTMENTS}}, {{ROLES_BY_DEPT}}) are filled in from .workforce-build-state.json + workforce-interview-answers.md at runtime.
Philosophy: Why a Skill, Not Inline Code
Same reason Skill 23's build-resume layer is a separate component:
- Reliability via state machine. Every step writes status to
.workforce-build-state.jsonbefore moving on. If the agent crashes between steps, the resume cron picks up exactly where it left off — no double-sending, no skipped step. - Cost control. Each KIE.AI call (image, image, video) has a retry-with-backoff cap so a stuck job doesn't burn credits.
- Idempotency. All Notion pages are created with a deterministic title prefix so re-runs detect "already done" and skip.
- Operator visibility. Trevor can inspect any client's closeoutStatus + the per-step URLs and know exactly what shipped.
Cost Envelope (Default Caps)
| Item | Model | Approx Cost | Cap |
|---|---|---|---|
| Infographic #1 | Local HTML + Playwright Chromium (no model call) | $0 | 0 retries needed (deterministic) |
| Infographic #2 | gpt-image-2-6/sunburst-text-to-image (fallback nano-banana-2) |
price: see price authority below | 3 retries |
| Celebration video | gemini-omni-video (fallback veo3_fast) |
price: see price authority below | 3 retries (with model fallback) |
| Notion pages | Notion API (free per workspace) | $0 | 3 retries per page |
| Telegram sends | openclaw message send | $0 | 3 retries per send |
Infographic #1 is free; only Infographic #2 + the celebration video hit KIE.
Price authority (one source): this skill states no KIE prices. Read the live price with python3 74-kie-live-adapter/scripts/kie_live_adapter.py price --model <id> (live pricingDesc, falling back to the snapshot 74-kie-live-adapter/references/kie-model-registry.json). Credit preflight rule: required balance = estimated cost x 1.30 (07-kie-setup/references/kie-common-rules.md).
One KIE Path: Skill 74
Every KIE call this skill makes (image job, video job, reference upload and re-host, result download) is the CLI of Skill 74 (74-kie-live-adapter/scripts/kie_live_adapter.py ... --mode active --json), called through scripts/lib-kie74.sh. Skill 74 is found as a sibling skill folder (like Skill 66 and 67). This skill keeps its own policy (model order, prompts, retry and fallback loop, 8.5 gate, state fields); it has no createTask, polling, upload or download code of its own. If Skill 74 is not installed the generators stop with a clear message; they never fall back to a second client.
Video Model Selection
Default video model across OpenClaw: Veo 3.1 via KIE.ai (model slug veo3 or veo3_fast). Any video gen elsewhere in the codebase should default to Veo 3.1.
For Skill 37 (ZHC closeout) celebration video specifically: Gemini Omni Video via KIE.ai (model slug gemini-omni-video). Reason: Gemini Omni accepts an image reference (we pass the just-rendered workforce-chart PNG), so the company's brand color, monogram, and CEO agent name carry through into the video. Veo 3.1 cannot accept image guidance.
Override via env var ZHC_CELEBRATION_VIDEO_MODEL:
ZHC_CELEBRATION_VIDEO_MODEL=gemini-omni-video # default (this skill)
ZHC_CELEBRATION_VIDEO_MODEL=veo3_fast # general-purpose fallback
ZHC_CELEBRATION_VIDEO_MODEL=veo3 # higher-quality Veo
The script also auto-falls-back from gemini-omni-video to veo3_fast on its third attempt if the Gemini Omni endpoint is unavailable on the KIE account.
Workforce-Structure Infographic: HTML, not AI image gen
Infographic #1 is rendered locally via HTML + CSS + a headless Chromium screenshot (Playwright). It is NOT a diffusion-model call.
Why: diffusion models (GPT Image 2.6, Nano Banana, Imagen) cannot reliably render small text labels. Early fleet closeout attempts came back with garbled department names and missing role counts. HTML + CSS gives perfect text every time, is free per render, and is fully deterministic.
The renderer lives in templates/workforce-org-chart/. See its README for details. Infographic #2 (How Work Flows) is stylized enough that AI image gen is still appropriate, and it uses GPT Image 2.6 sunburst (gpt-image-2-6/sunburst-text-to-image) first, as pinned fleet-wide by AGENTS.md N43, with Nano Banana 2 (KIE slug nano-banana-2; the marketing-name gemini-3-1-flash-image slug returns HTTP 422 on KIE and is NOT used) as the fallback. Skill 66 (66-kie-image) is the authoritative model registry; canonical KIE rules: 07-kie-setup/references/kie-common-rules.md.
Files in This Folder
| File | Purpose |
|---|---|
SKILL.md |
You are here — overview, pipeline placement, page-tree spec |
QUALITY-GATE.md |
MANDATORY 8.5 rate + QC gate: rubrics + workflow every deliverable must pass before client delivery |
INSTRUCTIONS.md |
Runtime guide: state machine, 6-step pipeline, retry/fail handling |
INSTALL.md |
One-time setup (env checks, skill registration) |
CORE_UPDATES.md |
Lines appended to workspace AGENTS.md |
CHANGELOG.md |
Version history |
skill-version.txt |
Machine-readable version pin — the single source of truth for this skill's version (read it at runtime; never hardcode the version elsewhere) |
scripts/run-closeout.sh |
Top-level orchestrator |
scripts/lib-kie74.sh |
The one KIE path: thin wrappers over Skill 74's CLI (image job, upload, re-host, run) used by the three generators |
scripts/generate-infographics.sh |
Infographic #1 local render; Infographic #2 KIE.AI call (sunburst first, nano-banana-2 fallback) |
scripts/generate-celebration-video.sh |
KIE.AI celebration video (primary gemini-omni-video; fallback veo3_fast/veo3) |
scripts/create-notion-closeout.sh |
Notion API page-tree creation |
scripts/send-telegram-celebration.sh |
7-message Telegram delivery |
scripts/send-operator-summary.sh |
Success-path operator Telegram summary with LINKS to every delivered artifact (via OpenClaw gateway; opt-in env.vars.OPERATOR_ESCALATION_CHAT_ID, back-compat ZHC_OPERATOR_CHAT_ID — NO hardcoded default; skips send when unset). Idempotent. |
scripts/upload-ghl-media.sh |
Conditional GHL media-library upload of the closeout media (Version 2021-07-28, LOCATION PIT only). Skips gracefully if GHL/Convert-and-Flow + a working PIT are absent. |
templates/infographic-1-prompt.md |
Structure infographic prompt template |
templates/infographic-2-prompt.md |
Workflow infographic prompt template |
templates/veo-prompt.txt |
Veo video prompt template |
templates/notion-page-tree.json |
9-section page-tree template |
Prerequisites
| Prerequisite | Required | Why |
|---|---|---|
Skill 23 build completed (buildCompletedAt set) |
MANDATORY | Without it, no data to close out |
| Skill 32 (Command Center Setup) installed | MANDATORY | Step 1 of pipeline calls Skill 32 |
Skill 07 (KIE.AI setup) installed + KIE_API_KEY env var |
MANDATORY | Steps 2-4 use KIE.AI |
Skill 74 (74-kie-live-adapter) installed |
MANDATORY | The only KIE transport (steps 3-4); no fallback client |
NOTION_API_TOKEN env var on the container |
MANDATORY | Step 5 uses Notion API |
NOTION_API_VERSION env var (defaults to 2022-06-28 if unset) |
RECOMMENDED | Notion API version pin |
openclaw message send working |
MANDATORY | Step 6 uses Telegram delivery |
jq on PATH |
MANDATORY | All scripts parse state file with jq |
curl on PATH |
MANDATORY | Notion HTTP calls |
Security Note
The Notion page tree is created in the client's own workspace, using the client's own NOTION_API_TOKEN. We never write to Trevor's Notion. The agent never logs the token, and never logs a prefix, suffix or any other substring of it: credential state is reported as SET or NOT-SET and nothing else. A prefix is still credential material, and terminal transcripts, agent logs and shell history retain every character printed.
The KIE.AI prompts include the company name, owner name, and department list. These are NOT secrets, but treat them as the client's PII — do not include them in CHANGELOG.md examples or in PR descriptions.
Verification Checklist (Post-Install)
After install completes:
-
~/.openclaw/skills/37-zhc-closeout/exists with all listed files -
scripts/run-closeout.shischmod +x -
KIE_API_KEYis set on the container — presence only, never the value:[ -n "$KIE_API_KEY" ] && echo "KIE_API_KEY: SET" || echo "KIE_API_KEY: NOT-SET" -
NOTION_API_TOKENis set on the container — presence only, never the value:[ -n "$NOTION_API_TOKEN" ] && echo "NOTION_API_TOKEN: SET" || echo "NOTION_API_TOKEN: NOT-SET" - At least ONE closeout trigger cron exists —
openclaw cron list | grep -E 'closeout-resume|workforce-build-resume'(v12.34.0: triggers are REDUNDANT; the dedicatedcloseout-resumecron needs no owner chat). Runscripts/qc-closeout-wiring.shto assert files+crons+state in one shot; re-runupdate-skills.sh(now backfills all pipeline crons viascripts/ensure-pipeline-crons.sh) if it FAILs.
Support
- INSTRUCTIONS.md — runtime
- INSTALL.md — one-time setup
- CHANGELOG.md — what changed in which version
- https://docs.openclaw.ai — platform docs