Files
actionbook__actionbook/docs/guides/cli-and-skills.mdx
Junliang Feng 6502eb87d8 docs: fix snippet import syntax for Mintlify (#187)
Replace unsupported <Snippet file="..."> component with standard
MDX import syntax. Mintlify requires ESM imports for reusable snippets.

Fixes install tabs not rendering on live docs site.

Affected pages:
- docs/guides/installation.mdx
- docs/quickstart.mdx
- docs/openclaw.mdx
- docs/guides/cli-and-skills.mdx
2026-03-04 17:24:16 +08:00

122 lines
4.1 KiB
Plaintext

---
title: "CLI & Skills"
description: "Master Actionbook with CLI and Skills"
---
import InstallTabs from "/snippets/install-tabs.mdx";
The Actionbook CLI and Skills/Workflows are the most powerful way to use Actionbook with AI agents.
## Using the CLI
The CLI allows you (and your agents) to search for actions, inspect them, and perform browser automation.
### Installation
<InstallTabs />
### Initial Setup (Recommended)
Run setup once after installation:
```bash
actionbook setup
```
This configures API key and browser preferences, then you can use the same `actionbook browser ...` commands in daily usage.
### Core Commands
#### Search Actions
Find available action manuals for a specific task or website.
```bash
actionbook search "airbnb search"
```
#### Get Action Details
Retrieve the full manual for a specific action ID.
```bash
actionbook get "site/airbnb.com/page/home/element/search-button"
```
#### Browser Automation
The CLI includes a built-in browser automation tool that uses the action manuals.
```bash
# Open a website
actionbook browser open airbnb.com
# Click an element using its verified selector
actionbook browser click '[data-testid="search-button"]'
# Fill a form field
actionbook browser fill 'input[name="location"]' 'Tokyo'
```
<Tip>
**Want to use your existing Chrome?** Run `actionbook setup` and choose extension mode once.
Install Actionbook from the [Chrome Web Store](https://chromewebstore.google.com/detail/actionbook/bebchpafpemheedhcdabookaifcijmfo), then keep using normal `actionbook browser ...` commands with your existing login sessions.
See the [Browser Automation Guide](/guides/browser) for setup and all available commands.
</Tip>
## Using Skills
Skills are enhanced capabilities that you can add to your AI agent's context. By adding the Actionbook skill, you give your agent a manual on *how* to use Actionbook effectively.
### Add the Skill
Run this command in your project root:
```bash
npx skills add actionbook/actionbook
```
This will download the skill definition to your `.skills` (or similar) directory.
### Benefits of Skills
1. **Context Awareness**: The skill provides the agent with specific instructions on when and how to call Actionbook CLI commands.
2. **Workflow Optimization**: It teaches the agent the optimal workflow: `search` -> `get` -> `operate`.
3. **Reduced Hallucinations**: By following the skill's procedure, the agent relies on verified action manuals instead of guessing DOM selectors.
### Example Agent Workflow
Once the CLI is installed and the Skill is added, you can simply ask your agent:
> "Go to Airbnb and search for a place in Tokyo."
The agent will:
1. **Read Skill**: Understands it should use `actionbook` CLI.
2. **Search**: Runs `actionbook search "airbnb search"`.
3. **Get**: Runs `actionbook get ...` to find the search input and button selectors.
4. **Operate**: Runs `actionbook browser ...` commands to perform the search safely.
### Extracting Data
The `extract` skill handles requests where the goal is **obtaining data** from a website.
If your current project only installed one skill, run `npx skills add actionbook/actionbook` again and select `extract` in the interactive step.
Ask naturally:
> "Extract all paper titles and authors from this arXiv search results page."
> "Scrape the pricing table from example.com/pricing into a CSV."
> "Pull all job listings from this page — title, company, location."
The agent will:
1. Search Actionbook for verified selectors.
2. If `actionbook get` already covers required fields, start from those selectors and draft the script quickly.
3. Run lightweight mechanism probes when needed (hydration/scroll/pagination checks).
4. Use snapshot/screenshot/inspect only when selectors are missing or fail in validation.
5. Generate a **standalone Playwright script** that handles detected page mechanisms.
6. Run the script and write the extracted data to disk.
The default output is an executable `.cjs` script + an `output.json` file. The script is re-runnable without Actionbook installed (as long as Node.js + Playwright are available), and the data file is the reusable extraction result.