hp-gen
Generate Astro pages and sections from page plans. Run /homepage-plugin:hp-plan first.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- hp-gen
- description
- Generate Astro pages and sections from page plans. Run /homepage-plugin:hp-plan first.
- allowed-tools
- Read, Write, Edit, Glob, Grep, Bash, Workflow
- argument-hint
- [page-name]
- user-invocable
- true
03 SKILL.md 正文
Code Generation Skill (3-Phase Pipeline)
Generates Astro pages, sections, and shared infrastructure from page plans (page-plan.json). The homepage-plugin:hp-gen-run workflow runs the agents and owns their order and stop rules; this skill owns what surrounds it: preconditions, locks, the user's confirmation, verification, progress and the summary.
Conventions: ${CLAUDE_PLUGIN_ROOT}/skills/hp-shared/SKILL.md.
Instructions
Step 0: Read Configuration
Read .claude/homepage-plugin.json. If not found, exit with instruction to run /homepage-plugin:hp-init.
Read defaultLocale — all user-facing output in this language.
Step 1: Validate Plans
If [page-name] argument provided:
- Validate
docs/pages/{page-name}/page-plan.jsonexists - Generate only this page
If no argument:
- Scan
docs/pages/*/page-plan.jsonfor all planned pages - If none found, exit with instruction to run
/homepage-plugin:hp-plan
Step 2: Check Generation State
For each page, check docs/pages/{page-name}/.progress/{page-name}.json:
- Status
planned→ proceed with generation - Status
generatedor later → warn about demotion and ask to confirm re-generation - Status
gen-failed→ checkgeneration-state.jsonfor resume opportunity
Resume support: If generation-state.json exists with incomplete phases, offer to resume from the last incomplete phase instead of starting over:
- Read
docs/pages/_shared/generation-state.json - If
phases.infrastructure.status === "completed"and the layout still exists → skip Phase 1 - For Phase 2, check each page's status — skip pages already marked as
completed, resume from firstpendingorfailedpage - Ask user: "Resume from {phase/page}? Or restart from scratch?"
Step 3: Acquire Lock
Take a lock for every page in the run, and one for _shared, because every run writes docs/pages/_shared/generation-state.json. Lock file path: docs/pages/{page-name}/.implementation/homepage/.lock
Lock file format (JSON):
{
"lockedBy": "hp-gen",
"lockedAt": "2026-03-23T14:30:00.000Z",
"pageName": "home"
}
Acquisition protocol:
- Check if
.lockfile exists - If exists → read
lockedAtfield → parse as ISO-8601 → compare with current time- If age < 30 minutes → release any lock this run took and exit with "Another homepage-plugin operation is in progress"
- If age >= 30 minutes → delete stale lock, log warning, proceed to step 3
- Write new
.lockfile withlockedBy: "hp-gen",lockedAt: new Date().toISOString(),pageName
Release: Always delete every .lock file this run took on completion or failure (in Step 8 and on any early exit).
Step 4: Confirm with User
Display the generation plan:
- Pages to generate
- Sections per page (static vs island)
- Shared infrastructure to create (if first page)
- Estimated components to generate
Ask user to confirm before proceeding.
Step 5: Run the Workflow
Make sure docs/pages/_shared/generation-state.json exists and lists every page in the run under phases.pages with status pending, keeping entries already there. When this run passes infrastructure, set phases.infrastructure to pending, so a session that dies inside that stage runs it again. page-assembler records each finished entry in this file, so progress survives a session that dies mid-run.
Call the Workflow tool with name: "homepage-plugin:hp-gen-run" and args:
projectRoot— project root pathconfig— homepage-plugin configuration objectstateFile—docs/pages/_shared/generation-state.jsonlayoutPlanFile—docs/pages/_shared/layout-plan.jsoninfrastructure—{ planFile }with the first page'spage-plan.jsonwhen no layout or shared components exist, or whenphases.infrastructureis recorded and notcompleted; otherwisenullpages—[{ pageName, planFile }]in order, leaving out pages a resume skipsfileKey— Figma file key from.claude/homepage-plugin.json(if available)mcpToolPrefix— MCP tool prefix (auto-detect from available tools:mcp__figma__*,mcp__figma_desktop__*, ormcp__Figma__*)
The workflow runs page-assembler for the infrastructure, then section-generator and page-assembler for each page in turn. Failed infrastructure stops the run. A failed page does not stop the next one.
Tell the user what will run. The result arrives as a task notification; continue at Step 6 when it does. If the call is refused or fails, release the locks and report it.
Step 6: Record Failures
From the workflow result, update generation-state.json:
stoppedAt: "infrastructure"— setphases.infrastructureto{ "status": "failed", "error": ... }, skip Step 7, and treat every page in the run as failed- each entry in
pageswithstatus: "failed"— setphases.pages.{page}to{ "status": "failed", "error": ... }from itsfailedAgentandfailure
{
"phases": {
"infrastructure": { "status": "completed", "completedAt": "2026-03-23T14:30:00Z" },
"pages": {
"home": { "status": "completed", "completedAt": "2026-03-23T14:32:00Z" },
"about": { "status": "completed", "completedAt": "2026-03-23T14:35:00Z" },
"contact": { "status": "failed", "error": "section-generator failed on ContactSection" }
}
}
}
Valid status values per phase: "pending", "completed", "failed".
Step 7: Phase 3 — Verification
Run verification checks:
- TypeScript —
npx tsc --noEmit - ESLint —
npx eslint .(skip if no config and eslintTemplate is false)- If
eslintTemplateis true and no ESLint config exists (no.eslintrc*oreslint.config.*):- Read
${CLAUDE_PLUGIN_ROOT}/templates/eslint-config.md - Extract the JavaScript code block from the "Canonical Config" section
- Write it to
{projectRoot}/eslint.config.jsusing the Write tool - Check dependencies:
pnpm ls eslint @eslint/js typescript-eslint eslint-plugin-astro eslint-plugin-react-hooks globals 2>&1 - If any dependency missing: display
pnpm add -D eslint @eslint/js typescript-eslint eslint-plugin-astro eslint-plugin-react-hooks globalsand skip ESLint (do not run) - If all present: run
npx eslint . 2>&1
- Read
- If
eslintTemplateis false and no config exists: skip ESLint entirely
- If
- Astro build —
npx astro build
Step 8: Update Progress
For each page, update docs/pages/{page-name}/.progress/{page-name}.json:
- The page failed in the workflow, or any verification fails → status:
gen-failed - Otherwise → status:
generated
Record verification results and timestamps.
Release the locks.
Step 9: Display Results
Show:
- Pages generated
- Sections created (new vs reused)
- Islands created
- Verification results (pass/fail per check)
- Next step guidance:
- If all passed: "Run
/homepage-plugin:hp-verifyfor full quality check, or/homepage-plugin:hp-reviewfor code review." - If failures: "Fix the errors above, then re-run
/homepage-plugin:hp-gen."
- If all passed: "Run
Communication Language
Read defaultLocale from .claude/homepage-plugin.json for all user-facing output.
04 同仓库更多 Skills
hp-shared
Shared conventions for every homepage-plugin agent and skill — stack, code conventions, state-file writes, check commands and how to report them. Preloaded into agents through their `skills:` frontmatter; not meant to be invoked by hand.
fe-shared
Shared conventions for every frontend-react-plugin agent and skill — code conventions, state files and locks, accepted deviations, design principles, build working directory, router-mode command matrix, TypeScript check. Preloaded into agents through their `skills:` frontmatter; not meant to be invoked by hand.
be-spring-shared
Shared conventions for every backend-springboot-plugin agent and skill — tech stack, CQRS architecture, naming, coding standards, TDD, commit and build rules, state files. Preloaded into agents through their `skills:` frontmatter; not meant to be invoked by hand.
pp-translate
Use after directly editing the working language spec to sync changes to other supported languages.
pp-sync-stitch
Use when wireframes were manually edited on the Stitch website and need to be re-fetched to the local project.
pp-sync-notion
Use when a specification needs to be published or re-synced to Notion after finalization or manual edits.