macros/- reusable helpers for common setup/navigation actions that stop in a navigable state for further interactive work.tests/- critical-scenario scripts for QA/perf verification that assert explicit outcomes (for example Sentry spans) and then stop.lib/- bash drive libraries for flows that need conditional steering the linear.adformat cannot express (snapshot classification, state-dependent branching). Each file documents its own contract; the caller always owns the session lifecycle (open/close/record). Source them from an orchestrator or run them standalone against an already-open session (for examplelib/sign-in-drive.sh --platform web --session <name> --email <email>).
Composable .ad snippets - bounded units of work. A flow may span one or multiple screens as long as it represents a coherent, reusable action with clear start (@pre) and completion (@post) checkpoints. Each flow advertises machine-matchable metadata (@pre, @post, @tag, @param) via # @-prefixed comment headers, while flow type is derived from location (flows/macros/ or flows/tests/).
Before manually navigating, use this human-in-the-loop loop:
agent-device snapshot -i- see current state.grep -H '^# @' .claude/skills/agent-device/flows/macros/*.ad- interactive catalog.- For each candidate flow, run
agent-device is exists "<selector>"per@pre. Keep flows where every@prepasses. - Rank survivors by goal closeness and present top macro candidates to the user with a short "why this flow" note:
- Prefer flows whose
@postselectors literally match destination language from the user request (sametext,label, or selector phrase).
- Prefer flows whose
- Wait for user selection before replaying. Auto-run is allowed only when there is exactly one survivor and it is an unambiguous match for an explicit user request.
- Only propose flows from
flows/macros/in interactive usage.
- Only propose flows from
- Scan selected flow
# @paramheaders. Ask the user for any missing parameter values, then build explicit CLI args (-e KEY=VALUE) for replay. agent-device replay <path> -e KEY=VALUE ....- If the flow declares
@post, verify each@postwithis exists. On success, re-enter the loop only if the user's stated goal is not complete; otherwise stop and report completion. On failure, propose peer flow/manual fallback options and ask before continuing. If no@postis declared (utility flow), rely on explicit user confirmation or the next snapshot before continuing.
flows/tests/ is reserved for dedicated QA automation and should not be offered to users as part of the interactive helper loop above. Run these flows with the dedicated test runner:
agent-device test .claude/skills/agent-device/flows/tests/<name>.ad -e KEY=VALUE ...Each flow starts with # @key value comment lines. The .ad parser treats # lines as no-ops, so headers cost nothing at replay time.
| Field | Cardinality | Value |
|---|---|---|
@desc |
1 | One-line human summary. |
@pre |
1..N | Selector that must resolve in the current snapshot. Multiple lines are ANDed. |
@post |
0..N | Selector expected after replay. Multiple lines are ANDed. Used for chaining + success. |
@tag |
0..N | Free-form category (auth, onboarding, ...) or scoped (sentry-<spanName>). |
@param |
0..N | Runtime input contract: @param KEY description. Use with ${KEY} in flow body. |
Selector syntax matches the body: id="...", role="..." label="...", text="...", || for fallbacks.
Declare runtime inputs via metadata (@param) and reference them in the body with ${VAR} interpolation. Values are supplied by caller arguments (-e) or shell imports (AD_VAR_*) - never by in-file env directives.
| Construct | Where | Purpose |
|---|---|---|
# @param KEY ... |
Metadata header comments | Declares expected input and documents meaning for the agent/user handoff. |
${KEY} |
Body | Interpolation point. Resolves at replay time. |
${KEY:-fallback} |
Body | Use fallback if KEY is unset. |
\${KEY} |
Body | Literal ${KEY} (escape). |
Resolution precedence (high to low): CLI -e KEY=VALUE (repeatable) > shell AD_VAR_KEY=... (auto-imported as KEY) > built-ins (AD_PLATFORM, AD_SESSION, AD_FILENAME, AD_DEVICE, AD_ARTIFACTS). Unresolved ${X} errors with file:line.
Override at runtime without editing the file:
agent-device replay <flow>.ad -e EMAIL=other@example.com- No
open, noclose, nocontextheader. Caller owns lifecycle. - No fixed
waitcalls.fill/pressresolve selectors with retry. Only addwait <selector>for real post-action blocks. - Durable selectors. Prefer
id=...first, thenrole=... label=..., with||fallbacks. Avoid@eNrefs. - Every flow declares
@descand@pre. Add@postfor outcome-bearing flows; utility flows (for examplego-back) may omit it. Add@tagwhen applicable. - Choose directory intentionally. Put reusable setup/navigation steps in
flows/macros/; put outcome verification scenarios inflows/tests/. - Keep scope coherent, not artificially tiny. Flows can span multiple screens when that sequence is the reusable intent (for example "create and submit manual expense").
- Peers share
@preand differ on@post. One flow per narrow outcome is better than a mega-flow with conditional branches. - Use
@paramfor substituted values. If a literal is interpolated into the body, declare# @param KEY description.and reference it as${KEY}. - Do not use
envdirectives in repo flows. Runtime values must come from-e KEY=VALUE(preferred) orAD_VAR_KEY=.... - Use inline defaults sparingly. Optional tuning values can use
${KEY:-fallback}in the body; required values should have no fallback and must be provided by caller input.
- Drive the target screen manually.
- Start a session with
--save-script:agent-device open <app> --save-script .claude/skills/agent-device/flows/<kind>/<name>.ad
- Perform the steps.
agent-device close- flushes the.ad.- Edit the generated file:
- Delete the
contextline, leadingopen ... --relaunch, trailingclose, and eyeballingwaits. - Move file to
flows/macros/orflows/tests/, then add@desc,@pre, optional@post, optional@tag, and any needed@paramheaders.
- Delete the
- Verify: pre-check from a matching state, replay, post-check.
Heal selector drift in place:
agent-device replay -u .claude/skills/agent-device/flows/<kind>/<name>.adRe-verify @pre/@post still hold, then commit. Note: replay -u can rewrite interpolated lines to concrete selectors/values; review diffs and restore ${KEY} placeholders where needed. Keep runtime inputs in @param + -e/AD_VAR_*; do not reintroduce in-file env directives.