Implementation Plan

Port the PDF Export Button to plan-agent Plans

completed
2026-06-12 agentics feature

Ship the Save as PDF button in every plan-agent generated HTML plan — port the window.print() export that landed in plan-interview (PR #272) into plan-agent's skeleton and SKILL.md output contract, so each new plan exposes one-click PDF export with zero external dependencies.

Implement Read and implement all steps in the plan at docs/plans/port-pdf-export-button-to-plan-agent.html — Port the Save as PDF button into plan-agent generated HTML plans. Start from the embedded digest: awk '!f && /<script[^>]*id="plan-digest"/{f=1;next} f && /<\/script>/{exit} f' docs/plans/port-pdf-export-button-to-plan-agent.html
File port-pdf-export-button-to-plan-agent.html
Path docs/plans/port-pdf-export-button-to-plan-agent.html
Acceptance criteria 6 / 6 done

Context

PR #272 (2026-06-07) added a Save as PDF button to HTML plans — but only inside the plan-interview plugin's markdown-to-html assets. Plans are actually generated by plan-agent's implementation-plan skill, which keeps its own independent reference/SKELETON.html, and that pipeline never received the button: 53 of 54 plans in docs/plans/ lacked it, including every plan generated since. Markdown plan conversion also moved into plan-agent (2.2.0), so no current generation path produced the export button. This plan ports the button markup, CSS, savePDF() function, and print-hide rule into the skeleton, and pins the requirement in the SKILL.md HTML output contract plus a smoke test so the two pipelines cannot silently diverge again.

Files to Modify

agentics/
  • kit/plugins/plan-agent/skills/implementation-plan/reference/SKELETON.html modified button markup, CSS, savePDF(), print hide
  • kit/plugins/plan-agent/skills/implementation-plan/SKILL.md modified Save as PDF bullet in HTML Output Requirements
  • kit/plugins/plan-agent/CHANGELOG.md modified 2.4.0 release entry
  • .claude-plugin/marketplace.json modified plan-agent 2.4.0 plus description mention
  • tests/plugins/test-save-pdf.sh new six-assertion smoke test
  • docs/plans/index.html generated gallery index rebuild

Steps

1
todo Add the Save as PDF button markup to the skeleton header
Place the button between the .plan-title heading and the status badge inside .plan-header-top in reference/SKELETON.html, wired as type="button" onclick="savePDF()" with an explicit aria-label. This matches the placement contract plan-interview's html-spec defined in PR #272, so both pipelines render the control in the same place.
Verify
Asserts 1–2 of bash tests/plugins/test-save-pdf.sh pass — the button sits between .plan-title and .status-badge with full type/onclick/aria-label wiring.
2
todo Style the button and hide it in print output
Add the .save-pdf-btn CSS block (accent background, hover/active/focus-visible states, prefers-reduced-motion opt-out) beside the status-badge styles, and append .save-pdf-btn to the main @media print hide list. The control must look native to the plan header and must never appear inside the PDF it produces.
Verify
Asserts 4–5 of the smoke test pass; opening the browser print preview shows no button.
3
todo Define savePDF() in the skeleton's inline script
Add function savePDF() { window.print(); } ahead of buildImplementPrompt(). The browser's native print dialog offers a "Save as PDF" destination on Chrome, Edge, Firefox, and Safari — zero dependencies keeps every plan a single self-contained file.
Verify
Assert 3 passes — the function exists in the inline script and calls window.print().
4
todo Pin the requirement in the SKILL.md output contract
Add a Save as PDF bullet to the HTML Output Requirements section of the implementation-plan SKILL.md covering placement, behaviour, print hiding, and the do-not-remove rule for both drafted plans and markdown conversions. The skeleton alone is not a contract — the spec bullet is what keeps future skeleton refactors and conversion mode honest.
Verify
Assert 6 passes — save-pdf-btn is documented in the SKILL.md.
5
todo Release plan-agent 2.4.0
Bump the plugin version in .claude-plugin/marketplace.json, mention the export button in the marketplace description, and add the 2.4.0 CHANGELOG entry. A new user-visible capability is a minor bump per the marketplace versioning rules.
Verify
marketplace.json shows plan-agent 2.4.0 and the CHANGELOG head reads "2.4.0 — Save as PDF button".

Tests

Tier 1 — Code-touching plan
Objective Generated plans ship a working Save as PDF control

File: tests/plugins/test-save-pdf.sh

Type: smoke test

Asserts: the skeleton every plan is generated from renders a Save as PDF button between the title and the status badge, wired to savePDF()window.print(), hidden in @media print, and required by the SKILL.md output contract.

Run: bash tests/plugins/test-save-pdf.sh

Integration Skeleton and SKILL.md contract stay in sync

File: tests/plugins/test-save-pdf.sh

Targets: reference/SKELETON.html header markup, inline script, and print styles; the SKILL.md HTML Output Requirements.

Key cases: button placement order, onclick and aria-label wiring, window.print() body, @media print hide list, CSS class definition, spec bullet presence.

Acceptance Criteria

Verification

Run bash tests/plugins/test-save-pdf.sh — all six assertions pass. Open this plan file in a browser: the header shows the Save as PDF button between the title and the completed badge; clicking it opens the native print dialog with a Save as PDF destination, and the button itself is absent from the print preview. Existing suites stay green: bash tests/plugins/test-plan-digest.sh.

Completion Checklist

Required

Completion Report

No items to report — all requirements met.

Next Steps

Backfill the Save as PDF button into existing plans

Paste this prompt into Claude to execute this follow-up:

Add the Save as PDF button to every existing HTML plan in docs/plans/ that lacks one. Follow the pattern of scripts/backfill-plan-digests.mjs: write scripts/backfill-save-pdf.mjs that inserts the .save-pdf-btn markup between the plan title and the status badge, the .save-pdf-btn CSS block, the @media print hide rule, and the savePDF() function into each docs/plans/*.html file missing them (idempotent, insertion-only, with --dry-run and --dir flags). Skip files that cannot be parsed confidently and report them. Run it, list the files changed, and commit the script together with the updated plans.
Wish List
Unify the duplicated HTML plan pipelines Wish List

Speculative / blue-sky idea — not on the critical path. Paste into Claude when ready to explore:

Investigate consolidating the two duplicated HTML generation pipelines in the agentics repo: plan-interview's markdown-to-html assets (kit/plugins/plan-interview/skills/markdown-to-html/) and plan-agent's implementation-plan skeleton (kit/plugins/plan-agent/skills/implementation-plan/reference/SKELETON.html). Features like the Save as PDF button (PR #272) have shipped in one pipeline and silently missed the other. Recommend one approach — a shared asset source, build-time extraction, or one plugin delegating to the other — with tradeoffs, and draft a migration plan. Do not implement until the approach is approved.