Copy-as-prompt button
Copy as prompt · Copy page · Open in ChatGPT/Claude
Every doc page carries a small split-button beside its title (and at the foot of the article). It turns the page into something an AI assistant can act on — framed by what kind of page it is. A Build playbook tells the assistant to execute the steps in your repo; a Learn guide tells it to tutor you; a system page tells it to help author the library.
What the control does — three payloads
Section titled “What the control does — three payloads”The button is one control with three outputs, each built from the same page metadata:
| Action | Builder (page-prompt.ts) | What you get | Use it when |
|---|---|---|---|
| Copy as prompt (main button) | buildPagePrompt() | The page wrapped in a persona + mission + rules preamble, then the full body | You want an assistant to act on the page (run the steps, tutor you, fill the template) |
| Copy page (menu) | buildPageMarkdown() | The raw page as clean Markdown — # title + > Source: + body, no persona wrapper | You want the plain content (paste into a doc, or into a chat where you’ll frame it yourself) |
| Open in ChatGPT / Claude (menu) | buildOpenAsk() | A short, persona-aware ask + the live URL (the assistant fetches the page itself) | You want to jump straight into a chat without pasting the whole page |
The persona system — framing by doc-type
Section titled “The persona system — framing by doc-type”The core idea: the receiving assistant’s role changes with the page’s doc-type, so the copied prompt produces the right behaviour. The preamble is built in three layers:
- Persona — who the assistant is (“You are a senior implementation assistant…”).
- Mission — what to do with this page (“Execute the procedure below in your real workspace…”).
- Rules — binding constraints (steps in order, verify against
# Expected:, checklist gates, stop-and-report…).
flowchart TD
A[Doc page] --> B["PageCopyPrompt.astro<br/>builds one meta object"]
B --> C{"resolvePersona()<br/>path type → kind → shelf"}
C --> D["Posture<br/>execute · verify · understand · use · evaluate · author"]
D --> E1["buildPagePrompt()<br/>Copy as prompt"]
D --> E2["buildOpenAsk()<br/>Open in ChatGPT / Claude"]
B --> E3["buildPageMarkdown()<br/>Copy page"]
E1 --> F[CopyPageButton.astro]
E2 --> F
E3 --> F
Doc-type → posture
Section titled “Doc-type → posture”| Shelf · type | Posture | The assistant becomes |
|---|---|---|
| build / playbooks · sops · runbooks | execute | Senior implementation assistant — runs the steps in your real repo |
| build / checklists | verify | Verification partner — confirms each item is genuinely done |
| build / blueprints | understand | Architecture advisor — explains the design before you touch code |
| learn / handbooks · guides · concepts · research · case-studies | understand | Technical tutor — explains, then helps you apply |
| resources / templates · kits · cheatsheets · reference | use | Hands-on assistant — adapts the artifact for your project |
| directory | evaluate | Research assistant — compares options and helps you choose |
system_docs · any …/meta/authoring/… page | author | ZajLibrary documentation assistant — the only place the “documentation assistant” framing is correct |
Routing precedence
Section titled “Routing precedence”resolvePersona() picks the posture in this order (most reliable first):
- Authoring override —
system_docsshelf or any…/meta/authoring/…path →author. - Path type segment —
<shelf>/<type>/…(the IA enforces this;content-path-audit.pyvalidates it). kindfrontmatter — fallback when the path type is unknown (the enum incontent.config.ts).- Shelf default — then a neutral
genericpersona.
Execution extras
Section titled “Execution extras”For execute pages the rules block also gets:
- Step-awareness — when a page has
stepNumber, a line like “This is step 1 of phase 1 (~10 min) — do only this step, then stop at its## Checklist.” - Category-scoped rules — CodeCanyon/Laravel pages (
category: laravelor acodecanyontag/collection) append a secrets-discipline rule. Narrow rules stay scoped — they never appear on unrelated pages.
How to extend it
Section titled “How to extend it”| You want to… | Do this in page-prompt.ts |
|---|---|
| Add a new doc-type | Add a row to TYPE_META ({ label, posture }), and to KIND_TO_SEGMENT if a kind value should map to it |
| Change a persona’s wording | Edit the relevant entry in POSTURES (persona / mission / rules / openAsk) |
| Add a category-scoped rule | Extend CODECANYON_EXECUTE_RULES (or add a sibling set + a guard in resolvePersona) |
| Surface a new metadata field | Add it to PagePromptMeta, pass it from PageCopyPrompt.astro, and add a metadataLines entry |
After any change, run npm run build — the persona text ships inside each page’s static HTML, so a green build plus a spot-check of the rendered data-prompt is the verification.