toy

toy

Perform Bilibili Toy platform creator operations using the Toy CLI (publish, update, preview, query, video binding, and troubleshooting). Trigger words: Toy release, publish Toy, toy create, upload Toy, Toy update, toy update, change Toy cover, change Toy password, Toy preview, submit Toy for review, my Toy, toy mylist, Toy list, Toy stats, toy stats, Toy PV/UV, Toy login, toy login, Toy deployment history, toy history, toy cli, Toy white screen, Toy 404, Toy page won't open, Toy asset path, Toy slug, Toy bind video, bind video, unbind video, toy video, which videos are bound to Toy, show Toy entry on video page, toy video mine. Use this skill when the user needs to publish or update a local frontend project/HTML/zip to the Toy platform, view their own Toys, check access stats, bind/unbind videos with a Toy, troubleshoot white screen / asset 404 issues after publishing, or manage local release history.

14stars
4forks
Updated 9/22/2026
SKILL.md
read-only
name
toy
description

Perform Bilibili Toy platform creator operations using the Toy CLI (publish, update, preview, query, video binding, and troubleshooting). Trigger words: Toy release, publish Toy, toy create, upload Toy, Toy update, toy update, change Toy cover, change Toy password, Toy preview, submit Toy for review, my Toy, toy mylist, Toy list, Toy stats, toy stats, Toy PV/UV, Toy login, toy login, Toy deployment history, toy history, toy cli, Toy white screen, Toy 404, Toy page won't open, Toy asset path, Toy slug, Toy bind video, bind video, unbind video, toy video, which videos are bound to Toy, show Toy entry on video page, toy video mine. Use this skill when the user needs to publish or update a local frontend project/HTML/zip to the Toy platform, view their own Toys, check access stats, bind/unbind videos with a Toy, troubleshoot white screen / asset 404 issues after publishing, or manage local release history.

toy: Toy Platform Creator CLI

Perform creator-side operations on the Toy platform using the toy binary (cobra CLI, server OAuth login): package and publish, update, preview, query, and bind videos. This skill does not include a fixed command matrix—the CLI is self-describing, and hardcoding field names leads to code drift. The skill only carries workflows and core rules.

When to Use

When users mention creator scenarios such as publishing a local project/HTML/zip to Toy, updating an existing Toy, viewing their Toy list or access statistics, binding or unbinding videos with a Toy, or checking publication history.

Do not use for:

  • The legacy script-based publishing flow—this skill replaces it, standardizing on the official toy binary.

Prerequisites

  1. toy is installed. Check using command -v toy; if not installed, guide the user through installation (refer to references/installation.md).
  2. Logged in. The first time any API command runs, it may return "Session expired, please run toy login". Handle this according to Core Rule 4.
  3. Global flags are subject to the actual output of --help-json.

Discovery Mechanism (Critical)

Do not construct commands from memory. Before using a subcommand for the first time, run:

toy --help-json

The output is structured JSON containing the full command tree, positional arguments, flags, writes annotations, and choices values. If you need a single subtree, run toy <cmd> --help-json.

JSON Field Semantics:

Field Purpose
commands[].path Command path array, e.g., ["create"], ["history","clear"]
commands[].args Positional parameters {min, max, names, variadic}
commands[].flags Flag list for this level, each containing type/default/choices/required
commands[].writes true indicates a business write operation (e.g., create/update)
global_flags Global flags (e.g., --json)

Try Upgrading when Features Are Missing

If a feature requested by the user truly cannot be found in --help-json (the command/flag does not exist, rather than being misspelled or misremembered), the local toy version might be too old or the feature hasn't arrived yet. In this case, you can attempt a single upgrade (command details in references/installation.md) and re-check --help-json. Upgrade failures (dev builds, unconfigured distribution URLs, offline status) are normal; directly reply to the user using existing capabilities that "the current version does not support this", without getting stuck or retrying repeatedly.

Core Rules

Execute in the following order of priority:

1. Always Use --json for AI Calls

Whether reading or writing, the AI must append --json when invoking toy. Table outputs from read commands (mylist/stats/history) break easily due to column width changes or hyperlink rendering; Chinese success messages from write commands are also harder to parse than structured responses. --json is the sole stable contract.

2. Publish/Update Is a Two-Step Process: "Preview → Confirm → Submit for Review", Not One-Step

When create / update (writes:true) includes a package payload, the CLI uploads the package and generates a preview_url, without submitting for review by default. Submission for review is triggered by --yes, acting as the true confirmation gate (the client side lacks risk annotations; preview serves as the gate).

Correct AI behavior:

  1. First run without --yes (with --json). The CLI returns only {"preview_url": "..."}, without submitting.
  2. Pass the preview_url to the user as-is so they can inspect it in their browser.
  3. Proactively initiate explicit confirmation (via AskUserQuestion or an equivalent clear query)—do not passively say "let me know when you've reviewed it". Present the notice "About to submit for review" alongside a summary of changes (target Toy's id/title/slug, what changed this time, and that the slug remains unchanged), asking the user to clearly reply "submit / do not submit". Only run again with the same parameters plus --yes after receiving an explicit affirmative response. If the user does not reply, gives a vague reply (e.g., "mhm" or "ok" without pointing to a submission action), or asks to edit further, do not append --yes.
  4. Upon successful submission, --json will return {id, status, preview_url}. Provide id/status to the user.

Rule details:

  • In non-interactive scenarios (AI invocation), --json without --yes = preview only, no submission; with --yes = submit directly. Never append --yes before the user has reviewed the preview and explicitly confirmed. After providing the preview, proactively ask "Submit for review now?" rather than waiting passively—weak prompts ("tell me when done") easily lead users to assume review is already underway.
  • Updating metadata only (update without path) yields no preview link and submits directly for review. This scenario also requires using AskUserQuestion to notify "About to submit for review: <change summary>" prior to adding --yes.
  • --visibility password must be paired with --access-password (4-32 characters); passing only --access-password defaults to password mode. Specific values/constraints depend on the choices in --help-json.

3. Perform Content Self-Checks Before Publishing Packages

toy only packages and uploads; it does not validate package content. Toy pages run under the /toy/<slug>/ subpath. Absolute asset paths or root absolute redirects will cause blank pages / 404s / broken links—the package uploads and may pass review, but opens broken. (Note: In-page anchor links href="#section" are now supported and no longer cause issues; see references/content-checklist.md §2.)

Before executing create / update with a path, perform a pre-check on <path> according to references/content-checklist.md: Prefer automated pre-check tools listed in the checklist. If unexecutable, manually review high-frequency traps following §1–§6 (absolute paths, hash routing vs. history routing, build output vs. source code, cover image, immutable slug). If there are ERRORs, inform the user first and fix them before uploading; do not force upload. WARN items must also be explained to the user one by one (WARNs do not change exit codes; the summary line still prints passed, skipping them means failing to check).

When doctor reports "HTML document is N MB", handle it according to checklist §8: This is a loading experience WARN that doesn't block publishing, but you must tell the user specifically what steps to take (many Toy upload developers are not professional engineers; telling them to "change to external assets" means nothing). The WARN specifies which format it is—“N chunks” means the bundler export format option was chosen incorrectly (change export format), while “one inline block” is the project's own code (move data to external files). The two prescriptions differ; read the corresponding steps from §8. Do not attempt to trim those tens of MBs yourself for either case.

When build artifact filenames lack content hashes (contenthash), toy_doctor.py reports a WARN. This is merely a suggestion: the package can still be published and accessed without hashes, but visitors will redownload all assets on every update. Mentioning it once is enough—do not block the workflow or alter build configurations for the user (most tools enable it by default; Vite works out of the box). See checklist §3.5 for details.

If the package uses Cloud Storage / Leaderboard SDK capabilities, review the call cadence in checklist §7. This differs from the items above: everything works fine during publishing, but breaks when player traffic spikes (exceeding Toy shared quota results in rejection error 307044), which cannot be detected in preview. Report it as a WARN without blocking deployment—just mention it once to the user and do not block the workflow. Thresholds are not public and are adjustable online; do not report specific numbers to the user or suggest hardcoding numbers for local throttling.

See references/content-checklist.md for details (§1–§6 calibrated with official FAQs or verified against CLI source code; §7 shares source with official SDK docs "Frequency Limits and Best Practices"; §8 originates from online loading duration tests on the platform side, not yet included in official FAQs).

4. Expired Login Session Requires Re-login

If the error message contains "Session expired", "Please run toy login", or the envelope code indicates session invalidation:

toy login

toy login triggers browser OAuth (opens a browser automatically; disable with --no-open). After logging in, retry the original command once. If it still fails, stop and report to the user—do not loop. See references/error-codes.md for details.

5. Destructive Local Operations Require Confirmation

history clear deletes all local publication records on the machine (local logs only, does not affect online Toys). It uses --yes to skip confirmation. When the AI needs to execute it, it must first ask for confirmation via AskUserQuestion before appending --yes. Other read-only commands (mylist/stats/whoami/history view) can be run directly.

6. Video Binding Takes Effect Immediately Without Preview/Review

video bind / video unbind modifies binding relationships (once bound, the video page displays a entry to the Toy). Calls take effect immediately: no preview, no version produced, no review process, and no --yes flag. Do not apply the two-step process from Rule 2.

Constraints not readable from --help-json:

  • A single video can only be bound to one Toy (conversely, one Toy can be bound to multiple videos). If encountering "This video is already bound to another work", explain the conflict clearly and let the user decide. Do not unbind it from another Toy on your own.
  • Duplicate bindings and unbinding non-existent relationships are idempotent and will not throw errors. No need to query before writing.
  • video mine only returns approved video submissions—if a video cannot be found, check whether it has passed review first.
  • The --json output of bind/unbind echoes back only the identifier passed; leaving the other empty is by design.
  • Unbinding is non-destructive (it can be bound again), so confirmation under Rule 5 is not required; however, ask first before unbinding any relationship not explicitly named by the user.

Typical Workflows

Workflows only anchor command names + business steps. Specific parameters / flags / values must be fetched using --help-json to prevent drift from the CLI.

A. Publishing a Local Project for the First Time

  1. Confirm login status (run toy login if necessary).
  2. Content Pre-check: Perform content pre-checks on <path> according to Rule 3 (refer to references/content-checklist.md). Fix ERRORs first; explain WARNs to the user one by one before proceeding—WARNs do not alter exit codes (remains 0) and summary lines still display passed; ignoring them is equivalent to skipping checks.
  3. Run create <path> (with --json, without --yes). <path> can be a directory / single HTML / existing zip. Metadata flags (name, slug, cover, icon, category, visibility, etc.) must be based on the current output of create --help-json—do not list them from memory, as these items may be added or removed across versions. If name/slug is omitted, it will be inferred from the path name.
  4. Obtain preview_url, present it to the user as-is, and ask them to inspect it in a browser.
  5. Proactively initiate explicit confirmation per Rule 2 (display change summary and ask the user to explicitly reply "submit"). After receiving an affirmative answer, rerun with the same parameters + --yes to submit for review.
  6. Parse the returned id/status and present it to the user.

B. Updating an Existing Toy

  1. Need the ID first: Run mylist (with --json) to list my Toys, and select the target id from the list.
  2. Updating with a package payload: Perform content pre-checks on <path> according to Rule 3 first, then run update <id> <path> (without --yes) → get preview_url → proactively initiate explicit confirmation per Rule 2 → receive affirmative reply → submit with same parameters + --yes. Preserve the original slug; do not delete and recreate to change the URL (slugs cannot be changed after publishing).
  3. Updating metadata only (no path, no preview link, direct submission): Check writable fields via update --help-json. Inform the user per Rule 2 before appending --yes.
  4. Changing password settings: --visibility password --access-password ...; to update the password of an existing password-protected Toy, pass only --access-password. Refer to --help-json for details.

C. Viewing My Toys and Statistics

  1. Run mylist (with --json, optional --page/--size) to view list and visibility.
  2. Single Toy statistics: stats <id>, default is the last 7 days (up to yesterday, current day not settled); set date range with --days N or --start/--end (YYYY-MM-DD, up to 90 days). Refer to --help-json for details. Scripts/JSON calls must explicitly pass id (omitting it triggers interactive selection, which fails in AI environments).

D. Inferring "New Publish vs. Update" Using Deployment History

When a user provides a local path and says "publish to toy", they often do not clarify whether it is an initial release or an update. Check release history first to disambiguate rather than jumping straight to create:

  1. Run history <path> (with --json) to check if this directory/file has been published previously. Records are isolated by logged-in account and store snapshots of past successful create/update executions (including id/title/source path, etc.).
  2. Evaluation:
    • Record found (matching id exists) → High probability of an update. Verify that the id still exists using mylist, then follow Workflow B (update <id> <path>). Confirm with the user first that this is an update to the existing record rather than a new publish.
    • No record found → Could be an initial release, or previously published from a different machine/account/path. Do not rely solely on local history: run mylist to check if a Toy with the same name/slug exists online, then confirm with the user whether to proceed with create (Workflow A) or update (Workflow B).
  3. Treat legacy toy.yaml as a read-only supplementary clue (leftover from legacy release workflows, not maintained by this skill). If history yields no results and you want further confirmation, read toy.yaml in the directory to extract id/slug/title as speculative clues—however, you must verify via mylist --json that the id still exists under the current account. Do not treat it as absolute fact, as it may be outdated or point to another user's project. Do not judge accounts based on owner_mid/uid inside it.
  4. Both history and toy.yaml are local clues only (do not affect online states, may be incomplete/outdated) and are not sources of truth. The actual online status is defined by mylist. If uncertain, let the user choose.

Clear history using history clear (destructive, append --yes only after confirmation per Rule 5).

E. Binding Videos to a Toy

Once bound, the video page displays an entry point to the Toy. You can only bind your own videos to your own Toys; ownership is validated server-side.

  1. Determine Toy: If unspecified by the user, run mylist to let the user confirm which Toy to select.
  2. Determine Video: Use the identifier directly if provided by the user (accepts BV IDs or av IDs; pure digits treated as av IDs). If omitted, run video mine to present candidates for selection (only approved submissions appear).
  3. Check Current Status (Recommended): Run video list to view what is currently bound to this Toy, helping identify if the user actually wants to rebind.
  4. Bind: Submit using video bind. Takes effect immediately without preview or review. Use video unbind to unbind.
  5. Encountering "This video is already bound to another work" → Per Rule 6, explain the conflict clearly and let the user decide. Do not unbind it yourself.

Scripts/JSON must explicitly pass Toy id (omitting it enters interactive selection, which fails in AI environments); parameter forms for accepting IDs vary across commands, subject to --help-json.

Error Handling Priority

  1. Session expired ("Session expired" message / session invalidation code) → toy login, retry once, do not loop.
  2. Business error (envelope code != 0 message) → Return message directly to user without secondary interpretation.
  3. Non-interactive environment prompt indicating "--yes is required" → Signifies preview/submission gate. Follow preview-confirmation workflow per Rule 2; do not blindly append --yes to bypass it.
  4. Flag/argument error (cobra reports unknown flag / accepts N arg(s)) → Re-run --help-json to align parameter structure.

What NOT to Do

  • Do not parse human help text (toy -h is for users; AI uses --help-json).
  • Do not construct flags from memory (commands may be updated or differ by build channel; verify every time).
  • Do not append --yes to create/update before the user has reviewed the preview and explicitly confirmed; do not wait passively for the user to speak—proactively ask "Submit for review now?" per Rule 2.
  • Do not skip content pre-checks before publishing packages (absolute path / root absolute redirect traps will cause broken pages); in-page anchors href="#section" are now supported and no longer error out—do not treat them as bugs (see references/content-checklist.md Section 2).
  • Do not perform "delete-and-recreate" to change a slug unless the user explicitly wants a new URL (slugs are immutable post-launch and must be preserved during updates).
  • Do not attempt to trim large inline blocks inside HTML yourself (rewriting tens of MBs byte-by-byte cannot guarantee fidelity, and silent corruption may occur). Modify the step that produced the HTML—export options or build scripts. Read steps to the user per checklist §8 instead of vaguely stating "change to external assets".
  • Do not create, write, or maintain toy.yaml by default (this skill uses official CLI local records; toy.yaml is for read-only compatibility); do not include toy.yaml in uploaded packages.
  • Do not loop retries on session expiration; do not write session tokens into any output.
  • Do not append --yes to destructive commands like history clear without confirmation.
  • Do not unbind a user's other Toys without authorization to complete a video binding.