--- name: ghost-skill-creation-guide description: "Skill Creator: author, validate, record with ghost skill demo, and publish Ghost hub skills. Load when authoring, editing, importing or reviewing a Ghost Skill Hub skill (skillhub/author/slug/skill.yaml): schema v2 fields, step primitives, validators, popups, checkpoint and ask, the author CLI flow, the quality ladder points, and do/don't rules. Also load when turning an agent trace of phone actions into a reusable skill." --- # Ghost Skill Creator How to author a Ghost Skill Hub skill, from scratch or from a recorded trace. Written for both people and LLM agents: read it once, then follow the flow in section 8. Field-level reference: `docs/skill-schema-v2.md`. Scoring source of truth: `skillhub/scoring/v1.json`. ## 1. What you are building A **skill** is a folder `skillhub///` that automates one app. It holds named **actions** (what an agent calls, e.g. `calculate`), each a list of deterministic **steps** ending in an **end_state_validator** that proves the action worked. Replay costs zero LLM tokens. Agents call it by name: MCP `run_skill(name="/", action, params)` or `ghost skill run `. - **Hard skill**: no LLM and no human at replay. - **Soft skill**: `SOFT.md` reference notes the agent reads with `get_skill_notes` when replay does not fit. - **Gate**: a checkpoint or ask suspends a run; a human captcha is a gate, not a soft skill. The schema's legacy `skill_class: soft` value marks gated execution. See `docs/skill-taxonomy-soft-vs-hard.md`. ### Toolkit shape Author an app toolkit with **one entry action**, **3–6 focused primitives**, and **one read-state action** that returns visible structured data. Add actions beyond that range only when the app needs distinct operations; this is an authoring rule, not a schema-enforced action limit. Entry opens or resets the demo app; primitives perform one operation; read-state observes without opening unrelated apps or changing user data. Reuse the toolkit across prompts instead of embedding one benchmark task in a single long action. Include a **Toolkit** table in README with each action's role, parameters, returned data and side effects. Document honest limits and the tested app/device scope. Record every action three times after the final definition-file edit; editing README, SOFT.md, helpers.py or skill.yaml changes the content digest. Prior runs remain historical evidence and do not verify the new files. For Android Python helpers, share the engine APIs instead of copying parsers or launching a separate ADB process: ```python from gitd.skills.engine.nodes import parse, by, centre nodes = parse(device.dump_xml()) rows = by(nodes, "id", "com.example:id/row") # centre(rows[0]) returns coordinates; it does not tap. png = device.screencap_png() # PNG bytes, transport errors and package policy checked ``` The node helpers preserve document order and raw XML attribute entities, reject invalid/off-screen bounds, and use exact selectors. Decode display text explicitly when needed. The screenshot API is Android-specific. Adopting either API in an existing recorded skill requires fresh content-bound runs after its final edits. Folder contents: ``` skill.yaml required, the skill README.md required for Runs tier SOFT.md one section per action; the narrative adapt mode reads when the UI drifts helpers.py optional python_action targets, flat file validators.py optional custom_python validators icon.webp optional, 96 px, <= 16 KB (tools/fetch_app_icons.py fetches Play/F-Droid icons) demos/.webm|mp4|gif + demos/.spec.yaml optional, one clip per action runs/ your signed self-runs (ghost skill run --record) verifications/ other people's signed runs, added by their PRs SKILL.md GENERATED by the registry builder, do not edit ``` ## 2. skill.yaml top level ```yaml name: calculator # = folder slug version: 1.0.1 # SemVer; bump on every change to an existing skill author: ghost # = GitHub login = folder name description: "One line: what it automates" skill_class: hard # hard | soft license: MIT # SPDX id, required generated_with: "Claude Opus 5.5 via Claude Code, hand-explored on an emulator" # required; say how it was made status: active # active | blocked | deprecated | draft side_effects: [none] # sends_message, posts_content, makes_payment, modifies_account, deletes_data, none destructive: false # true requires a confirm gate (checkpoint/ask) or a dry-run param tos_risk: low # low | medium | high locale: [en-US] # BCP-47 list you tested in data_access: [] # contacts, sms, camera, mic, location, notifications, clipboard, files, storage icon: icon.webp # optional; defaults to icon.webp when present demo: demos/convert_units.webm # optional default clip; else first action clip fingerprint: os: android # android | ios os_version: ">=14" hardware: "*" # do not wildcard what you did not test unless it is truly generic app_package: org.fossify.math app_version: ">=1.4.0" screen_wxh: 1080x2400 # optional density: 420 # optional locale: en-US # optional theme: "*" # optional: light | dark | * os_popup_policy: {allow_permissions: [], deny_permissions: [], ignore: []} # Layer 1 overrides popup_detectors: [] # Layer 2 subroutines: [] actions: [] ``` Reserved, set by the registry, never by you: `trust`, `quality`, `schema`. ## 3. An action ```yaml - name: convert_units # snake_case, agent-facing description: "Convert a value between two units" ref_prompt: "Convert 100 Fahrenheit to Celsius" demo_params: {category: Temperature, value: "100", from_unit: Fahrenheit, to_unit: Celsius} params: - {name: category, type: enum, values: [Length, Temperature], required: true} - {name: value, type: str, required: true, description: "number"} pre_hooks: [] # optional steps before steps: on_popup: {} # Layer 3 (section 5) steps: [...] end_state_validator: {all_of: [...]} # required; 3+ leaf checks earn points test_case: ref_prompt_variants: ["how many kilometers is 26.2 miles", "convert 70 kg to pounds"] expected_success: true ``` Param types: `str`, `int`, `float`, `bool`, `path`, `enum` (with `values`), `list[str]`. Interpolate with `{param}` and `{context.}` in any step string or validator. `demo_params` are the defaults `ghost skill demo` uses when no `--param` is given: pick values that show the action well and touch nothing private. CLI `--param` values are converted by the parameter declaration in both `ghost skill run` and `ghost skill test`: `--param value=005` stays `"005"` for `type: str` and becomes `5` for `type: int`. Boolean-looking text and JSON-looking text also stay literal strings when declared `str`; `bool` and `list[str]` declarations parse them accordingly. Typed API values and YAML defaults declared `str` are normalized to strings. ## 4. Steps Write steps as `{action: , ...}`. The structural steps (`if_visible`, `retry`, `subroutine`, `checkpoint`, `ask`, `python_action`) use their name as the key. **26 step kinds**: the 20 primitives below (18 device, wait and read steps plus `python_action` and `checkpoint`) and the 6 control-flow steps in the next table. | Step | Use when | |---|---| | `tap_element {id\|desc\|text\|xpath}` | Default way to tap. Locator chain id, desc, text, xpath | | `tap {x, y}` | Only for landmarks with no stable attribute; add a comment why | | `type_text {text, clear_first?}` | Type into the focused field | | `long_press {x, y \| id\|desc\|text, duration_ms}` | Context menus, drag starts; a locator long-presses the node's centre | | `swipe {x1, y1, x2, y2, duration_ms?}` | Scrolling, pagers | | `press_key {key}` | BACK, HOME, ENTER and other keyevents | | `launch_app {package, activity?}` | Start the app (usually first step of a subroutine) | | `launch_intent {intent_action, package?, mime_type?, extras?}` | Share intents and deep links; skips whole UI flows | | `open_url {url, browser?}` | Web flows | | `screenshot {save_as?}` | Evidence for debugging, stored with the run | | `dump_xml {save_as?}` | Snapshot the a11y tree for a helper | | `dismiss_popups` | Extra Layer 2 sweep at a known popup moment | | `wait_for_text {text, timeout_s?}` | Wait until text shows (prefer over sleep) | | `wait_for_element {id\|desc\|xpath, timeout_s?}` | Wait until an element exists | | `sleep {duration_s}` | Last resort; animations with nothing to wait for | | `read_text {id\|desc\|text, store_as, attr?, index?, all?, parse?}` | Read a node into `{context.}` and the result; `all: true` collects every match, `parse: number` converts | | `tap_nth {id\|desc\|text, index}` | Tap the nth match of a locator (negative counts from the end) | | `compare {left, right, mode?, tolerance?}` | Fail unless the values agree (`equals`, `contains`, `number`, `regex`); the YAML way to check a read value | | `python_action: "helpers:fn"` | Anything YAML cannot express; `(device, params, context)` returning `dict` or `ActionResult` | | `checkpoint: {...}` | A gate the bot must not clear itself (section 6) | **Control flow and composition:** | Step | Use when | |---|---| | `if_visible: {selector, then, else?}` | Optional screens: dialogs, onboarding, a screen left open by a previous run | | `retry: {steps, max, backoff_s}` | Flaky landings, cold starts | | `subroutine: ` | Shared preamble across actions (e.g. `open_calculator`); define under `subroutines:`, not agent-callable | | `run_skill {name: /, action, params}` | Reuse another skill's action (e.g. a login skill) | | `ask: {...}` | Collect one typed answer from a human or an agent (section 6) | | `for_each: {over, as, map?, skip?, strict?, steps}` | Repeat steps per character or list item; inner steps use `{{context.}}` and `{{context._mapped}}` (double braces survive the outer pass) | `python_action` targets resolve by file path relative to the skill dir (`helpers:fn` is `helpers.py`). Dotted `gitd.*` paths are rejected. Helpers may call `device.dump_xml()`, `device.tap()`, `device.adb(...)`, write results to `context.result`. Return a plain payload dict, such as `{"count": 5}`, to merge its fields into `context.result`. `ActionResult(success=True, data=payload)` and `{"success": True, "data": payload}` are also supported. Dict keys `success`, `error` and `data` identify a result envelope: if your payload uses those names, put it under `data`. A result with `success=False` fails the step. Security tiers (`docs/skillhub/security.md`; enforced except APK sources and automatic Tier 3 rejection) decide what CI runs unattended: a YAML-only hard skill for an allowlisted app runs on the emulator automatically (Tier 1); any submitter Python, or an app not on the allowlist, waits until a maintainer has read it and added `approved:` (Tier 2); network calls from skill code, secrets, arbitrary APK URLs and obfuscated code are rejected (Tier 3). Prefer YAML when it can express the flow. ## 5. Validators and popups **7 validator kinds**, composable with `all_of`, `any_of`, `not` (a bare list means all_of): | Kind | Use when | |---|---| | `text_visible {text, exact?}` | The terminal screen shows a known string (supports `{param}`) | | `element_present {id\|desc\|text}` | A specific element proves the screen | | `url_contains {substring}` | Browser or WebView flows | | `pixel_at {x, y, rgb, tolerance?}` | Toggle state with no a11y signal | | `ocr_text_present {text, region?}` | Text drawn on canvas, not in the a11y tree | | `screen_hash {ref_hash, similarity_min?}` | Visually fixed screens | | `custom_python {function: "validators:fn"}` | Parsing or comparing values; `(device, context) -> bool` | **4 popup layers**, outermost first: 1. **OS catalog** (engine): permission dialogs denied, battery and update nags dismissed. Override per skill with `os_popup_policy`. 2. **`popup_detectors`**: `{detect: "text", button: "Not now", label: "..."}` for this app's nags. First match wins. Runs only before steps that read the a11y tree. 3. **`on_popup`** per action: when a popup is part of the flow, `{"