diff --git a/README.md b/README.md index 740eb0158..ccda6c754 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,34 @@ Apify CLI is the command-line tool for creating, developing, and deploying [Apif - Manage secret environment variables used by your Actors - Works with any programming language — Actors run as Docker containers on the platform +## Agent skill + +This repo ships an [agent skill](./skills/apify/SKILL.md) that teaches AI coding agents (Claude Code, Cursor, etc.) how to work with the Apify CLI reliably. You can print the skill straight from the CLI — it always matches your installed version: + +```bash +apify help --skills +``` + +If you'd rather have the skill installed persistently, `apify help --skills` prints a valid `SKILL.md` that you can redirect into your agent's skills directory. The location depends on the agent: + +### Claude Code + +```bash +mkdir -p ~/.claude/skills/apify +apify help --skills > ~/.claude/skills/apify/SKILL.md +``` + +### Codex and other agents + +Codex and most other agents follow the [Agent Skills open standard](https://developers.openai.com/codex/skills), which loads skills from `.agents/skills` (per repo) or `~/.agents/skills` (per user): + +```bash +mkdir -p ~/.agents/skills/apify +apify help --skills > ~/.agents/skills/apify/SKILL.md +``` + +That copy is a snapshot; re-run it after upgrading the Apify CLI to refresh it. + ## Quick start 1. **Install the CLI** (macOS / Linux): @@ -29,15 +57,14 @@ Apify CLI is the command-line tool for creating, developing, and deploying [Apif apify login ``` -3. **Create, run, and deploy** your first Actor: +3. **Run an Actor** on the Apify cloud: ```bash - apify create # it will walk you through an interactive wizard - cd my-actor - apify run - apify push + apify call apify/hello-world --output-dataset ``` + This runs the public [`apify/hello-world`](https://apify.com/apify/hello-world) Actor and prints its results. To build your own Actor instead, run `apify create` and follow the interactive wizard. + ## Installation ### macOS / Linux (bundle, recommended) diff --git a/docs/reference.md b/docs/reference.md index ca2b9fe31..3bc59c58a 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -21,10 +21,14 @@ DESCRIPTION Prints out help about a command, or all available commands. USAGE - $ apify help [commandString] + $ apify help [commandString] [--skills] ARGUMENTS commandString The command to get help for. + +FLAGS + --skills Print the Apify CLI agent skill (guidance for driving + `apify` from agents). ``` ##### `apify upgrade` @@ -782,7 +786,8 @@ FLAGS DESCRIPTION Executes Actor remotely using your authenticated account. Reads input from local key-value store by default. - Inspect the input schema first with "apify actors info --input". + To inspect the input schema before creating a JSON input, use "apify actors + info --input". USAGE $ apify actors call [actorId] [-b ] @@ -799,8 +804,8 @@ FLAGS -b, --build= Tag or number of the build to run (e.g. "latest" or "1.2.34"). -i, --input= Optional inline JSON object - input for the Actor. Wrap the JSON in quotes to avoid - shell parsing issues. For JSON files, use --input-file. + input for the Actor. To avoid shell parsing issues, wrap + the JSON in quotes. For JSON files, use --input-file. -f, --input-file= Optional path to a file with JSON input to be given to the Actor. The file must be a valid JSON file. You can also specify `-` to read from diff --git a/package.json b/package.json index 9ef746bcd..021c77a38 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "prepare": "husky" }, "files": [ - "dist" + "dist", + "skills" ], "bin": { "actor": "./dist/actor.js", diff --git a/scripts/build-cli-bundles.ts b/scripts/build-cli-bundles.ts index e710ab5cc..f021f40ca 100644 --- a/scripts/build-cli-bundles.ts +++ b/scripts/build-cli-bundles.ts @@ -68,6 +68,7 @@ const entryPoints = [ // target below to the matching `@napi-rs/keyring-` subpackage so Bun's `--compile` // embeds that one native `.node`. Must match the specifier in `src/lib/credentials.ts`. const KEYRING_PLACEHOLDER = '__APIFY_KEYRING_NATIVE_SUBPACKAGE__'; +const APIFY_CLI_SKILL = readFileSync(new URL('../skills/apify/SKILL.md', import.meta.url), 'utf-8'); // Maps the compiled (os, arch, libc) to the napi-rs keyring subpackage that ships its `.node`. // `supportedArchitectures` (pnpm-workspace.yaml) forces all of these into node_modules at build @@ -110,6 +111,9 @@ for (const entryPoint of entryPoints) { files: { [entryPoint]: lines.join('\n'), }, + define: { + __APIFY_CLI_SKILL__: JSON.stringify(APIFY_CLI_SKILL), + }, outdir: fileURLToPath(new URL(`../bundles/fat-clis`, import.meta.url)), conditions: 'node', target: 'bun', diff --git a/skills/apify/SKILL.md b/skills/apify/SKILL.md new file mode 100644 index 000000000..1b9284f58 --- /dev/null +++ b/skills/apify/SKILL.md @@ -0,0 +1,111 @@ +--- +name: apify-cli +description: Patterns for invoking the Apify CLI (`apify`) from agents. Covers authentication, creating/running/pushing Actors, calling Actors in the cloud, and reading results from datasets and key-value stores. +--- + +## Start here + +Run `apify -h` first to see the available commands and global options, then `apify -h` (e.g. `apify call -h`) for the args and flags of a specific command. This is the source of truth — prefer it over assumptions. + +## Non-interactive use + +Many commands prompt when run interactively. To run without prompts, pass every required argument and flag explicitly: + +- `apify create --template