AI Skill Report Card

Refactoring User Journeys

A-86·Dec 1, 2026·Source: Web

Refactoring User Journeys

Scope: information architecture, state management, edge cases. Never comment on styling, layout, spacing, color, or visual design.

14 / 15

Given a flow, produce this artifact first, before proposing any change:

JOURNEY MAP: Link device to entry (CURRENT)
User goal: "Have this device attached to this entry"

1. Open Entries → New Entry → fill form → submit        [entity A created]
2. Navigate to Devices → New Device → fill form → submit [entity B created]
3. Open Entry → Link Device → select device → submit    [relation created]

Steps: 3 forms, 3 submits, 2 navigations
Context loss: entry context dropped at step 2
Failure state: user abandons after step 1 → orphan entry
Memory load: user must remember entry name through step 2

Then produce the refactor:

JOURNEY MAP: Link device to entry (PROPOSED)
1. Open Entry (new or existing)
2. In "Devices" section: [Select existing] or [Create new inline]
3. Submit once → entry + device + link created atomically

Steps: 1 form, 1 submit, 0 navigations
Recommendation▾
Add a genuinely contrasting example with a different shape (e.g., a many-to-many relation carrying link data, or a flow where inline creation is the wrong answer). Both current examples are the same device/entry domain, and Example 2 is a thin summary rather than a full input/output pair.
14 / 15

Copy and track progress:

Progress:
- [ ] Step 1: Define the user goal (one sentence, outcome-focused)
- [ ] Step 2: Map the current journey (steps, entities, state, context)
- [ ] Step 3: Score friction (steps, context loss, memory load, dead ends)
- [ ] Step 4: Model the information architecture (entities and relations)
- [ ] Step 5: Define state ownership (server, form, URL, local)
- [ ] Step 6: Redesign the flow (collapse, defer, inline, prefill)
- [ ] Step 7: Enumerate edge cases and specify handling
- [ ] Step 8: Specify implementation with TanStack Query + React Hook Form
- [ ] Step 9: Compare before/after metrics

Step 1: Define the user goal

Write the goal as an outcome, not a task sequence. "Link a device to an entry" is the goal. "Create entry, create device, link them" is the current implementation. If the goal statement contains "then", it's describing the implementation.

Step 2: Map the current journey

For each step, record: action, entity touched, state required, where state lives, what the user must remember.

Step 3: Score friction

Count and report these (no subjective adjectives):

MetricHow to count
Interaction stepsClicks, submits, and navigations from intent to goal
Forms/submitsDistinct form submissions
Context switchesRoute changes that drop the primary entity
Memory loadFacts the user must carry between screens
Dead endsStates with no forward path (empty selectors, missing prerequisites)
Partial-failure surfacePoints where abandonment leaves inconsistent data

Step 4: Model the information architecture

Identify entity dependencies and cardinality before touching the flow:

Entry 1 ──── 0..N Device     (many-to-one? many-to-many?)

Answer these, since they dictate the right flow:

  • Can a device exist without an entry? (If yes, creation order is not forced.)
  • Can a device belong to multiple entries? (If yes, selection from existing is a first-class path.)
  • Which entity does the user think of as primary? Anchor the flow there.
  • Is the relation itself carrying data (e.g., installed date)? If yes, it needs its own fields in the flow.

Rule: Anchor the flow on the entity the user already has in context. Create dependent entities from inside it, never in a separate area of the app.

Step 5: Define state ownership

Assign every piece of state exactly one home:

StateHomeWhy
Server entities (entries, devices)TanStack Query cacheSource of truth, shared across views
In-progress inputReact Hook FormValidation, dirty tracking
Selected entry / wizard step / filtersURL search paramsSurvives refresh, shareable, back-button works
Ephemeral UI (dialog open)Local useStateNot worth persisting

Never duplicate server data into form state or useState. Pass IDs, derive from the query cache.

Step 6: Redesign the flow

Apply these transformations in order of preference:

  1. Inline creation: Replace "go create X first" with a create-in-place affordance inside the selector (combobox with "Create '{query}'" option, or a dialog that returns the new ID).
  2. Single submit, multi-entity: One form owning nested fields; submit via one mutation (or one server action/API endpoint) that creates and links atomically.
  3. Prefill from context: Carry the parent ID through the URL (/devices/new?entryId=123) and prefill or hide the relation field.
  4. Defer optional work: Required fields first; move optional fields to after the link succeeds.
  5. Return-to-origin: After any detour, route the user back to where they were with the new entity selected.
  6. Smart defaults: Preselect the only option, the most recent, or the one implied by context.

Step 7: Enumerate edge cases

For every redesigned flow, answer all of these explicitly:

  • Empty state: No devices exist → selector offers create path, not an empty dropdown.
  • Partial failure: Device creates, link fails → rollback server-side, or keep device and surface retry for link only.
  • Duplicates: User creates a device that already exists → detect on name/serial, offer to select existing.
  • Abandonment: User leaves mid-flow → no orphan records, or drafts are explicitly marked and recoverable.
  • Refresh/back button: Flow position and selections survive (URL state).
  • Concurrent edits: Device was deleted/linked elsewhere while selecting → handle 404/409 with a recoverable message.
  • Permissions: User can create entries but not devices → degrade the affordance, don't dead-end.
  • Validation across entities: Errors from the nested entity map back to the right field.
  • Double submit: Disable on pending, make the mutation idempotent.
  • Large lists: Selector uses async search, not a preloaded list.

Step 8: Specify implementation

Atomic multi-entity flow with nested form and one mutation:

TypeScript
// schema: one form owns the whole journey const schema = z.object({ title: z.string().min(1), device: z.discriminatedUnion("mode", [ z.object({ mode: z.literal("existing"), deviceId: z.string().min(1) }), z.object({ mode: z.literal("new"), name: z.string().min(1), serial: z.string().optional() }), z.object({ mode: z.literal("none") }), ]), }); const mutation = useMutation({ mutationFn: createEntryWithDevice, // single endpoint/server action, atomic onSuccess: (entry) => { queryClient.invalidateQueries({ queryKey: ["entries"] }); queryClient.invalidateQueries({ queryKey: ["devices"] }); router.push(`/entries/${entry.id}`); }, });

Inline creation from a selector, returning the new ID to the parent:

TypeScript
const createDevice = useMutation({ mutationFn: api.devices.create, onSuccess: (device) => { queryClient.setQueryData(["devices"], (old) => [...(old ?? []), device]); form.setValue("deviceId", device.id); // auto-select the new entity }, });

Implementation rules:

  • Use the discriminated union to model "existing vs new vs none" so invalid combinations are unrepresentable.
  • Prefer one server endpoint for multi-entity writes; avoid client-side chaining of dependent mutations (non-atomic).
  • If chaining is unavoidable, sequence in mutateAsync and compensate on failure.
  • Use optimistic updates only for the link, not for entity creation that needs server IDs.
  • Keep wizard step and selected IDs in useSearchParams.

Step 9: Compare before/after

Always close with a metrics table using the Step 3 measures. Report numbers, not opinions.

Recommendation▾
Include at least one explicit bad-outcome example, such as a refactor that looks simpler but fails (inline creation that breaks on permissions, or a single-submit form that loses atomicity). Currently bad patterns appear only as bullet-list pitfalls, not as concrete before/after cases.
15 / 20

Example 1: Input: "User must create an entry, then a device, then link them. Rethink this."

Output:

GOAL: Attach a device to an entry.

CURRENT: 3 forms, 3 submits, 2 navigations, entry context lost at step 2,
orphan entry on abandonment, user must remember entry identity.

IA FINDINGS:
- Entry is the primary entity (user starts from it).
- Device can pre-exist and be shared → "select existing" must be a first-class path.
- Link carries no extra data → no separate link form needed.

PROPOSED FLOW:
Entry form → "Device" field (combobox):
  a) search/select existing device
  b) "Create '{query}'" → inline dialog (name, serial) → returns ID → auto-selected
  c) skip (device optional)
Single submit → atomic create entry (+ device) + link.

STATE:
- Server data: TanStack Query (["entries"], ["devices"])
- Form: React Hook Form with discriminated union {existing|new|none}
- Entry ID for post-create redirect: from mutation response

EDGE CASES:
- No devices yet → combobox shows only the create option.
- Duplicate serial → inline error offers "Use existing device".
- Link fails after device created → server rolls back transaction; client shows retryable error with form data intact.
- Abandonment → nothing persisted (atomic submit).

RESULT: 1 form, 1 submit, 0 navigations, 0 orphan states.

Example 2: Input: "Linking from the Device page: user opens a device and must go find the entry."

Output:

FINDING: Anchor entity is the device here; flow should mirror the pattern.
Device detail → "Link to entry" → async-search combobox with inline
"Create entry" → on success, link and stay on device page with the new
entry visible. Pass context via ?deviceId= so the create-entry route can
prefill and return-to-origin after submit.
Recommendation▾
Tighten for conciseness: the Step 1 'then' heuristic, the Step 7 edge case list, and the Best Practices/Common Pitfalls sections restate points already made in Steps 4-8 (atomic writes, URL state, empty selectors, client-chained mutations appear 2-3 times). Merge or cut the duplication to reduce length without losing content.
  • Start from the user's goal and primary entity, never from the data model's creation order.
  • Make dependency creation a detour with a guaranteed return, not a prerequisite.
  • Put flow state in the URL so refresh and back work for free.
  • Treat every selector as having three modes: select existing, create new, none.
  • Make multi-entity writes atomic server-side; the client should not orchestrate consistency.
  • Invalidate narrowly by query key; update the cache directly when you already hold the new entity.
  • Specify every empty, error, and conflict state, since they're part of the journey.
  • Always quantify the improvement with the Step 3 metrics.
  • Wizard by reflex: Splitting into steps when a single form with inline creation has fewer steps overall.
  • Mirroring the database: Making the UI order match table creation order.
  • Duplicated state: Copying query data into useState or form state, causing stale views.
  • Client-chained mutations: Create A, then B, then link, with no rollback story.
  • Ignoring the empty selector: A dropdown with zero options and no path forward.
  • Losing context on detour: Navigating away to create a dependency without a return path or prefilled relation.
  • Happy-path only: Delivering the new flow without partial-failure, duplicate, and abandonment handling.
  • Drifting into visuals: Commenting on layout, styling, or components' appearance; stay on structure, state, and logic.
0
Grade A-AI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
14/15
Workflow
14/15
Examples
15/20
Completeness
17/20
Format
14/15
Conciseness
12/15