π§ Skill System
Ghostβs Skill System is what turns a probabilistic LLM-driven phone-driving loop into a deterministic, replayable, community-contributable library of $0 automations.
If youβre here to understand the architecture, youβre in the right place. If youβre here to use skills, start with Using Skills. If youβre here to author skills, start with Creating Skills.
The hierarchy
Section titled βThe hierarchyβSkill (a package)βββ fingerprint (os Γ hw Γ app-version this is verified against)βββ status (active | blocked | deprecated, default active)βββ license, generated_with, side_effects, destructive, tos_risk, localeβββ data_access (permissions the skill uses β informational)βββ popup_detectors (skill-scoped popups auto-dismissed mid-flow)βββ os_popup_policy (permission grant/deny overrides)βββ subroutines[] (internal reusable step-lists β de-dup helpers)βββ actions[] (agent-invocable, first-class) βββ ref_prompt (natural-language phrase LLM matches against) βββ params[] (typed inputs, {name} interpolation) βββ pre_hooks[] (python_action prep before device flow) βββ steps[] (the flow β atomic primitives + control flow + composition) βββ end_state_validator (composable predicate on terminal screen) βββ test_case (canonical prompt variants + expected success)Everything lives in skill.yaml next to a flat helpers.py (Python for python_action: escape hatches).
New skills must declare license: (an SPDX id such as MIT) and generated_with: (how the skill was written, for example hand or the tool that produced it). side_effects: (sends_message, posts_content, makes_payment, modifies_account, deletes_data, none), destructive:, tos_risk: (low, medium, high) and locale: describe what the skill does to the world; a destructive: true skill needs a confirm_before: gate or a dry_run param. You can check a file in the browser at Validate a skill.
Why action-first
Section titled βWhy action-firstβv1 split skill code into actions/ (atomic Python classes) + workflows/ (compositions calling actions) β two tiers, two Python conventions, one confusing distinction because both were called βactionsβ in the wild.
v2 collapses to one first-class thing β the Action β with clear ancillary primitives for the different needs it was solving:
| v1 concept | v2 replacement | Why |
|---|---|---|
actions/ (atomic Python classes) | Not needed β atomic ops are yaml primitives (tap, wait_for_element, etc.) or python_action: escape hatches | LLMs can emit YAML from a trace; Python classes are opaque to them |
workflows/ (multi-step compositions) | actions: with inline steps: | The composition IS the action β one thing, one name |
| Shared prelude Python between workflows | subroutines: (named reusable step-lists in the same yaml) | De-dup without inventing a βhelper actionβ that isnβt agent-invocable |
Now: every named thing an agent can invoke is an Action. Every Action has ref_prompt + end_state_validator + test_case. Every Action can be tested, benched, and validated in isolation.
The action lifecycle
Section titled βThe action lifecycleβWhen you call ghost skill run ghost/tiktok get_active_account --device asus:
- Loader parses
skillhub/ghost/tiktok/skill.yamlβ typedSkillDefw/ validated Schema v2 conformance - Runner builds a
RunContext(params, result, device_serial, popup detectors, os_popup_policy, skill_dir) - Runner resolves params against the actionβs
params[]β type-checks, fills defaults, validates enums - Pre-hooks β any
pre_hooks: [{python_action: ...}]fire before device steps (media prep, TTS injection, etc.) - For each step in
steps[]:- Interpolate
{param}and{context.attr}placeholders in every string field - Layer 1 OS popup sweep (permission dialogs, battery-opt, etc.) β only before a11y-reading steps
- Layer 2 skill popup sweep (from
popup_detectors:) β same selectivity - Dispatch to step handler (16 built-in step types, pluggable registry)
- Layer 4 safety net: if step failed AND a11y-diff shows a new modal appeared β screenshot + BACK cascade + retry ONCE β else
UnknownPopupErrorwith screenshot
- Interpolate
- Validator on end_state_validator β kind-dispatch (7 built-in, composable via all_of/any_of/not)
- Result β structured
RunResult(success, data, error, duration_ms, trace[])β never raises
Full engine internals: Execution Engine.
Step primitives
Section titled βStep primitivesβAll available via yaml step syntax (see the βstepβ grammar):
Atomic device interactions:
tap, tap_element (id/desc/text locator chain), type_text, long_press, swipe, press_key, launch_app, launch_intent (full Android Intent w/ mime_type + URI extras), open_url, screenshot, dump_xml, dismiss_popups.
Waits:
wait_for_text, wait_for_element, sleep.
Control flow:
if_visible: {selector, then: [...], else: [...]}, retry: {max, backoff_s, steps: [...], on_failure}, run_skill: {name, action, params} (cross-skill composition), subroutine: <name> (in-skill composition), checkpoint: {reason, prompt, success, timeout_s} (HITL gate for soft skills).
A checkpoint: step pauses at a gate the bot must not clear itself, such as a captcha or an emailed code. The run is marked awaiting_human and shows the prompt; it continues when a person resumes it (POST /api/skills/runs/{id}/resume for dashboard and MCP runs) or when the stepβs success: validator passes, and ends timed_out after timeout_s (default 600). A dry run, run_action(..., dry_run=True), needs no device: it resolves params, passes checkpoints straight through and lists every other step as skipped, which makes it a cheap smoke test for a skillβs structure.
Escape hatch:
python_action: <module>:<function> β arbitrary Python callable receiving (device, params, context), returns ActionResult. Required for real-world complexity (custom validators, media prep, OCR helpers). Raises trust tier β Community submissions with python_action: get extra reviewer attention.
Validator primitives
Section titled βValidator primitivesβCompose via all_of / any_of / not. Leaf kinds:
text_visible: {text}β a11y tree substring matchelement_present: {id | desc | xpath}β element in treeurl_contains: {substring}β WebView URLpixel_at: {x, y, rgb, tolerance}β screencap pixel color checkocr_text_present: {text, region?}β RapidOCR on screencap (optionally in a region)screen_hash: {ref_hash, similarity_min}β perceptual hash match against referencecustom_python: {function}β arbitrary Python predicate(device, context) -> bool
Example:
end_state_validator: all_of: - {kind: text_visible, text: "Sent"} - any_of: - {kind: element_present, id: sent_check_icon} - {kind: pixel_at, x: 990, y: 1200, rgb: [34, 187, 51]} - not: {kind: text_visible, text: "Failed to send"}Popup handling (4 layers)
Section titled βPopup handling (4 layers)βTT-style flake was the #1 pain of v1 skills. v2 handles it at four layers so authors barely think about it for the common case:
- Layer 1 β engine-global OS popups: permission dialogs, battery-opt, Google Play nag, screen-recording confirm. Always-on, deny-by-default (with per-skill
os_popup_policy.allow_permissions[]opt-in). - Layer 2 β skill-scoped
popup_detectors:in skill.yaml. Auto-dismissed before every a11y-reading step. - Layer 3 β action-level
on_popup:override for popups that are PART of the flow (Ad Authorization, cookie consents that must be accepted specifically). - Layer 4 β safety net: unknown modal detected after step failure β dismiss cascade β retry once β screenshot +
UnknownPopupErrorif still failing. Screenshot becomes the seed for extending the skillβs detector catalog.
Trust, quality and status
Section titled βTrust, quality and statusβEvery skill on the Skill Hub carries two separate badges, and the author sets neither of them:
- Trust comes from where the skill lives: Official (
skillhub/ghost/*), Verified (a community folder merged through a reviewed PR), Unverified (installed from a URL outside the hub; the installer asks first), Quarantined (blocked). - Quality comes from evidence: Draft, Runs, Proven, Hardened, Reference, earned with signed run artifacts, independent runs on other devices, validators and docs. See Scoring.
The author does set status:. A blocked skill cannot finish on its own right now (for example a mandatory phone check); the hub hides it by default and the installer warns, but it still installs.
Upgrading v1 skills
Section titled βUpgrading v1 skillsβOlder skills were Python packages (actions/ and workflows/ classes) or FLOW.md notes. ghost skill migrate <path> wraps one as a Schema v2 skill in place without deleting any v1 file: each v1 action or workflow becomes a v2 action whose single step is a generated python_action adapter, and a FLOW.md-only soft skill becomes an open_url plus a checkpoint:. It also generates SOFT.md. Re-running it refreshes the generated block, and --dry-run reports what would change.
Where this fits
Section titled βWhere this fitsβSkills sit between agents and the MCP Server:
Agent (Claude / Codex / GPT / etc) β MCP tool: run_skill(name, action, params) βΌGhost Skill Engine β loads skill.yaml β dispatches steps βΌDevice (Android via ADB / iOS via WebDriverAgent)Agents can use skills, and agents can author skills β the βLLM emissionβ mode of the schema is intentional: an LLM that just drove the phone can dump its own tool-call trace and get a near-1:1 YAML back. See Creating Skills for the traceβyaml recipe.
Reference
Section titled βReferenceβdocs/skill-taxonomy-soft-vs-hard.mdβ hard vs soft, 3-tier acquisition, empirical basisdocs/skill-schema-v2.mdβ full YAML spec, every primitive, composition rules- Execution Engine β runtime internals
- Skill Hub β registry + community + trust
- Skill Creator β the auto-BFS Skill Miner
- Publishing Skills β PR submit flow