---
name: journey
description: Self-contained HTML user-journey map (boxes/arrows with per-page modals) — preview between PRD and tech-design.
disable-model-invocation: false
argument-hint: "[] [--from-prd ] [--from-yaml ] [--update] [--wireframe]"
allowed-tools: Bash, Read, Grep, Glob, Write
effort: medium
---
Writing: read docs/skills/shared/writing-rule.md before you write a durable artifact.
# /journey — User-Journey HTML with Modal-Per-Page Design Preview
Generate a single self-contained HTML file at `projects//journeys/.html` mapping the user journey as clickable boxes (each opening a modal with the page's content). Companion skill to `/c4` (architecture preview) and `/threat-model` (security preview) — closes the gap on **flow-level** preview before any implementation.
## When to use
| Trigger | Use `/journey`? |
|---------|----------------|
| PRD approved, about to start tech design | Yes — visualises the flow the PRD describes, surfaces missing states |
| Stakeholder review of a new feature flow | Yes — single-file HTML, opens in any browser, shareable as an attachment |
| Quick "what does this look like as a flow?" sketch | Yes — conversational mode is 5 questions |
| Per-page visual design (high-fidelity mockups) | No — `/journey` is flow-first; per-page mockups are designer territory |
| Architecture diagrams | No — use `/c4` for L1/L2 architecture |
| Production deliverable HTML | No — the artifact is a draft preview, not production code |
## Activated role
When `/journey` runs, activate the **[UX Designer](../../../roles/design/ux-designer.md)** role — they own user flows and information architecture. For PRD parsing in mode (a), the **[Product Manager](../../../roles/product/product-manager.md)** is the supporting role (they wrote the PRD). See [`.claude/rules/role-triggers.md`](../../rules/role-triggers.md) for the full activation protocol.
## Path resolution
Read the registry path via `portfolio_registry`, the per-project docs dir via `portfolio_projects_dir`, and the ideas backlog via `portfolio_ideas_backlog` — all from `.claude/hooks/_lib-portfolio-paths.sh`. Source the helper at the top of any bash block that touches those paths:
```bash
source "$(git rev-parse --show-toplevel)/.claude/hooks/_lib-read-config.sh"
source "$(git rev-parse --show-toplevel)/.claude/hooks/_lib-portfolio-paths.sh"
projects_dir=$(portfolio_projects_dir)
```
Defaults match today's single-fork layout (`./apexyard.projects.yaml`, `./projects`). Adopters in split-portfolio mode override the `portfolio.{registry, projects_dir}` keys in `.claude/project-config.json`. Don't hardcode literal `projects/` paths in bash blocks — the helper resolves whichever mode the adopter is in. See `docs/multi-project.md`.
**Write targets** (see me2resh/apexyard#373 + #443): paths documented as `projects//X` in this skill are canonical adopter-facing forms — implement them in bash as `"${projects_dir}//X"`. Never construct from `"${PWD}/projects/..."`, `"$(git rev-parse --show-toplevel)/projects/..."`, or a literal `./projects/...` — those break in split-portfolio v2 mode where `projects_dir` resolves to a sibling repo.
**REQUIRED per-block preamble** (see #443): Claude executes each ```bash``` block as a separate shell invocation. The `projects_dir` assignment from the Path resolution section above does NOT carry into later blocks. Every bash block that writes to a `projects//X` path MUST start with this three-line preamble so it's self-contained:
```bash
source "$(git rev-parse --show-toplevel)/.claude/hooks/_lib-read-config.sh"
source "$(git rev-parse --show-toplevel)/.claude/hooks/_lib-portfolio-paths.sh"
projects_dir=$(portfolio_projects_dir)
# ... now write to "${projects_dir}//X"
```
The Path resolution section's example sources the helper *once* for documentation purposes; it does not absolve later blocks from sourcing it themselves. Treat each ```bash``` fence as a fresh process.
## Usage
```
/journey # conversational — asks for project, feature, pages, transitions
/journey checkout-v2 # conversational, feature pre-named
/journey checkout-v2 --from-prd projects/example-app/prds/checkout.md
/journey checkout-v2 --from-yaml projects/example-app/journeys/checkout-v2.yaml
/journey checkout-v2 --update # regenerate HTML from existing YAML
/journey checkout-v2 --wireframe # ask for inline HTML wireframe sketches in modals (v1, optional)
```
Argument shape:
| Form | Behaviour |
|------|-----------|
| No args | Conversational mode; ask for the project + feature first |
| `` only | Conversational mode for that feature (slug becomes the filename) |
| `--from-prd ` | Parse pages + transitions from a PRD file |
| `--from-yaml ` | Load structured journey data from a YAML file |
| `--update` | Re-render the HTML from `.yaml` without re-asking |
| `--wireframe` | (Default OFF) ask the agent to sketch HTML wireframes inline in each page's modal |
`--from-prd` and `--from-yaml` are mutually exclusive. `--update` is mutually exclusive with both — it always reads from the existing YAML.
## Output location
Files are written under the **per-project docs dir** (resolved via `portfolio_projects_dir`):
| File | Path | Purpose |
|------|------|---------|
| YAML source-of-truth | `//journeys/.yaml` | Editable, diff-reviewable, regenerable input |
| HTML build artifact | `//journeys/.html` | Single self-contained file — no external deps |
Both are committed. The YAML so reviewers can diff flow changes across PRs; the HTML so reviewers don't need to re-render to see it.
## Process
### 1. Resolve the target project
Same pattern as `/feature`, `/bug`, `/c4`:
- If invoked from `workspace//` → `` is the project.
- If invoked from the ops-fork root → ask which project this journey is for (list registered projects from `apexyard.projects.yaml`).
- If exactly one project is registered → use it without asking.
- If a `` argument was passed and a journey already exists at `//journeys/.yaml`, infer the project from that path.
### 2. Resolve the feature slug
The slug becomes the filename (without extension). Prefer kebab-case, max 40 chars.
- If `` was passed as the first positional arg → use it.
- If `--from-prd ` and the PRD has a clear title → derive a slug from the title.
- Otherwise → ask: "What's the feature name? (used as the filename)".
### 3. Source the journey data
Three input modes — pick whichever the operator's flags imply, or ask if ambiguous.
#### Mode (a) — From a PRD
Triggered by `--from-prd ` (relative to the ops-fork root or absolute).
Read the PRD. Look for these structural cues to extract pages and transitions:
| Cue | Inferred |
|-----|----------|
| `## User Flow` / `## User Journey` / `## Flow` heading | Section to parse for pages |
| Numbered steps under "Flow" / "Journey" / "Steps" | Each step is a page candidate |
| `- User clicks X → goes to Y` patterns | A transition from current page to Y |
| `## Pages` / `## Screens` heading | Each subheading is a page |
| `## Acceptance Criteria` with Given/When/Then | Pre-conditions / post-conditions = transitions |
| Mermaid `graph` or `flowchart` blocks | Direct edge list |
If the PRD is too prose-heavy to parse mechanically, fall back to mode (b) but pre-fill the conversation with the PRD's title, problem statement, and any explicit flow notes.
#### Mode (b) — Conversational
Default mode when no `--from-*` flag is given. A 5-question micro-interview:
1. **Pages** — "What pages / screens / states are in this flow? (one per line, name + 1-line description)"
2. **Entry point** — "Which page does the user land on first?"
3. **Transitions** — "What are the transitions? Format: ` -> on ` (e.g. `Login -> Dashboard on submit`). One per line."
4. **Personas** — "Are there multiple personas (e.g. user / admin / system)? Optional — leave blank for single-persona."
5. **Notes** — "Any global notes about the flow? (e.g. 'all pages require auth except Login')"
Capture answers verbatim into the YAML structure below.
#### Mode (c) — From YAML
Triggered by `--from-yaml ` or `--update` (which uses the canonical path `//journeys/.yaml`).
Load the YAML as-is. Validate it has the required top-level keys; if not, surface what's missing and stop.
### 4. Validate the journey graph
Before writing files, sanity-check:
- **Every page is reachable.** Walk transitions from the entry page; flag any unreachable page.
- **Every `to:` and `from:` references a page that exists.** Typos here are the most common mistake.
- **Hard cap at 12 pages.** A v1 journey with more than 12 pages is almost certainly two journeys; ask the operator to split.
- **Hard cap at 30 transitions.** Same reasoning — too dense to render readably.
If validation fails, list the issues and ask the operator how to fix (the conversation is cheap; rendering an unreadable graph is expensive).
### 5. Persist the YAML
Write `//journeys/.yaml` with this shape:
```yaml
version: 1
feature:
project:
title:
description:
generated_at:
generated_by: /journey
# Optional persona dimension. When absent, single-persona flow.
personas: [] # or: [user, admin, system]
# Pages = nodes in the graph.
pages:
- id:
title:
persona:
description:
contents:
-
-
success_state:
error_state:
image:
wireframe_html:
# Transitions = directed edges.
transitions:
- from:
to:
trigger:
# Entry point: the first page the user lands on.
entry:
# Optional notes shown on the journey overview.
notes: |
Multi-line notes about the flow, prerequisites, etc.
```
Write the file. If it already exists and `--update` was NOT passed, ask before overwriting (the YAML may have hand edits the operator wants to keep).
### 6. Render the HTML
Generate `//journeys/.html` — a **single self-contained file** with all CSS and JS inline. No `