ghst CLI Skill
This skill wraps the ghst CLI tool, which allows the agent to interact directly with any Ghost instance via the Ghost Admin API.
Prerequisites & Installation
For this skill to function, the ghst binary must be available in the system's $PATH.
Local Installation
Install the CLI globally using npm:
CODEBLOCK0
Alternatively, you can run it via npx without a permanent installation (though this is slower for repeated agent tasks):
CODEBLOCK1
Docker / Containerized Environments
If you are running OpenClaw in Docker, ensure the ghst binary is included in your container image by adding the installation command to your Dockerfile:
CODEBLOCK2
Configuration & Authentication
To interact with a Ghost instance, the agent requires a Ghost API URL and a Ghost Staff Access Token. There are two main ways to achieve this within the ghst skill:
- 1. Explicit flags:
--url and INLINECODE7 - Environment variables:
GHOST_URL and INLINECODE9
Instructions for Bot Owners
- 1. Navigate to your Ghost Admin panel.
- Go to Settings -> Staff (or Users) -> Edit your User Profile.
- At the bottom, generate or copy a Staff Access Token.
Option 1 — ~/.openclaw/.env (recommended for personal use)
Add the variables directly to your ~/.openclaw/.env file:
CODEBLOCK3
Option 2: openclaw.json skill entry (per-skill injection)
In ~/.openclaw/openclaw.json, add an env block under your skill's entry:
CODEBLOCK4
Once configured, restart your agent or wait for the config to be picked up.
Advanced Environment Variables
For complex setups, the following environment variables are supported:
| Variable | Description |
|---|
| INLINECODE15 | Canonical URL of the Ghost instance. |
| INLINECODE16 |
{id}:{secret} for Admin API access. |
|
GHOST_CONTENT_API_KEY | Hex key for Content API access (via
ghst api --content-api). |
|
GHOST_API_VERSION | Target API version (e.g.,
v5.0). Defaults to latest. |
|
GHOST_SITE | Default site alias/profile to use. |
|
GHST_CONFIG_DIR | Custom path for CLI configuration. |
|
GHST_OUTPUT | Set to
json to force JSON output globally. |
|
NO_COLOR | Disable ANSI color sequences. |
Agent Guidelines & Usage
When operating the ghst skill, the agent must adhere to the following rules to ensure robust and safe usage.
1. Robust Scripting
- - Always use
--json or --jq: Ensure your commands produce machine-readable JSON output rather than human-readable text.
ghst post list --json
ghst post list --json --jq '.posts[].title'
- - Use
--non-interactive: Since you are running in an automated environment, never issue commands that prompt for user input unexpectedly. Use --yes in combination with --non-interactive for any required destructive operations that you have received user approval for.
ghst comment delete <comment-id> --yes --non-interactive
- - Non-Interactive Auth: If you need to authenticate a new site programmatically:
CODEBLOCK7
2. Editing Posts and Pages
For detailed instructions on the "Read-Edit-Write" workflow to edit post or page lexical content (including minor rewording and URL changes), see the editing.md reference.
3. Searching and Filtering Posts and Pages
When you need to find specific posts or pages (e.g., by title, status, or tag), refer to the advanced filtering and NQL query examples documented in post.md and page.md.
Command Reference
Detailed documentation for each resource can be found in the references/ directory:
Manage pages and static content. |
|
ghst tag | Create and manage site tags. |
|
ghst member | Manage members, imports, exports, and bulk operations. |
|
ghst socialweb | ActivityPub feeds, profile management, and social interactions. |
|
ghst comment | Moderate, hide, show, and delete comments. |
|
ghst newsletter | Create and manage newsletters and bulk settings. |
|
ghst tier | Manage membership tiers. |
|
ghst offer | Create and manage subscription offers. |
|
ghst stats | Site analytics, growth reporting, and post traffic. |
|
ghst setting | Retrieve and update site-level settings. |
|
ghst image | Upload media assets to Ghost. |
|
ghst theme | Upload, activate, and validate site themes. |
|
ghst label | Label management for members and content. |
|
ghst user | Manage staff users and retrieve profile info. |
|
ghst site | General site information. |
|
ghst webhook | Configure and listen for Ghost webhooks. |
|
ghst migrate | Import tools for WordPress, Medium, Substack, and CSV. |
|
ghst auth | CLI authentication, site switching, and token management. |
|
ghst config | CLI tool configuration and defaults. |
|
ghst api | Direct raw API explorer for Admin and Content APIs. |
Example Workflows:
- * Bulk Post Tagging: INLINECODE58
- Member Cleanup: INLINECODE59
- Analytics Export: INLINECODE60
- Social Interaction: INLINECODE61
4. Safe Operation & Protections
- - Approvals & Notices: You must explicitly ask the user before performing destructive commands or bulk updates. Note: The CLI emits
GHST_AGENT_NOTICE: lines on stderr when a manual confirmation is interrupted. If you see this, you must stop and ask the user for explicit approval. - Destructive Commands: Always use
--yes --non-interactive for the following once approved:
-
ghst member bulk --action delete
-
ghst label bulk --action delete
-
ghst socialweb delete
-
ghst auth logout
-
ghst auth link (when replacing active link)
- - File Safety: CLI tools like
member export and migrate export will refuse to overwrite existing files. Check for file existence before exporting if necessary. - Security Check: Never print or output sensitive tokens (e.g., values coming from
ghst auth token or config --show-secrets) into the chat unprompted. Treat them as privileged credentials.
ghst CLI 技能
该技能封装了 ghst CLI 工具,使代理能够通过 Ghost Admin API 直接与任何 Ghost 实例进行交互。
前提条件与安装
要使此技能正常运行,ghst 二进制文件必须位于系统的 $PATH 中。
本地安装
使用 npm 全局安装 CLI:
bash
npm install -g @tryghost/ghst
或者,您可以通过 npx 运行它而无需永久安装(但对于重复的代理任务来说速度较慢):
bash
npx @tryghost/ghst --help
Docker / 容器化环境
如果您在 Docker 中运行 OpenClaw,请确保通过将安装命令添加到 Dockerfile 中将 ghst 二进制文件包含在容器镜像中:
dockerfile
RUN npm install -g @tryghost/ghst
配置与认证
要与 Ghost 实例交互,代理需要 Ghost API URL 和 Ghost 员工访问令牌。在 ghst 技能中,有两种主要方式可以实现这一点:
- 1. 显式标志:--url 和 --staff-token
- 环境变量:GHOSTURL 和 GHOSTSTAFFACCESSTOKEN
机器人所有者说明
- 1. 导航到您的 Ghost 管理面板。
- 转到 设置 -> 员工(或 用户)-> 编辑您的用户资料。
- 在底部,生成或复制一个 员工访问令牌。
选项 1 — ~/.openclaw/.env(推荐个人使用)
将变量直接添加到您的 ~/.openclaw/.env 文件中:
env
GHOST_URL=https://your-blog-url.ghost.io
GHOSTSTAFFACCESS_TOKEN=your-staff-access-token-id:secret
选项 2:openclaw.json 技能条目(按技能注入)
在 ~/.openclaw/openclaw.json 中,在技能条目下添加一个 env 块:
json
{
skills: {
entries: {
ghst: {
enabled: true,
env: {
GHOST_URL: https://your-blog-url.ghost.io,
GHOSTSTAFFACCESS_TOKEN: your-staff-access-token-id:secret
}
}
}
}
}
配置完成后,重新启动您的代理或等待配置被加载。
高级环境变量
对于复杂设置,支持以下环境变量:
| 变量 | 描述 |
|---|
| GHOSTURL | Ghost 实例的规范 URL。 |
| GHOSTSTAFFACCESSTOKEN |
用于 Admin API 访问的 {id}:{secret}。 |
| GHOST
CONTENTAPI_KEY | 用于 Content API 访问的十六进制密钥(通过 ghst api --content-api)。 |
| GHOST
APIVERSION | 目标 API 版本(例如 v5.0)。默认为最新版本。 |
| GHOST_SITE | 要使用的默认站点别名/配置文件。 |
| GHST
CONFIGDIR | CLI 配置的自定义路径。 |
| GHST_OUTPUT | 设置为 json 以全局强制输出 JSON 格式。 |
| NO_COLOR | 禁用 ANSI 颜色序列。 |
代理指南与使用
在操作 ghst 技能时,代理必须遵守以下规则以确保稳健和安全的用法。
1. 稳健的脚本编写
- - 始终使用 --json 或 --jq:确保您的命令生成机器可读的 JSON 输出,而不是人类可读的文本。
bash
ghst post list --json
ghst post list --json --jq .posts[].title
- - 使用 --non-interactive:由于您在自动化环境中运行,切勿发出意外提示用户输入的命令。对于您已获得用户批准的任何必需的破坏性操作,请结合使用 --yes 和 --non-interactive。
bash
ghst comment delete
--yes --non-interactive
- - 非交互式认证:如果您需要以编程方式认证新站点:
bash
ghst auth login --non-interactive --url https://blog.com --staff-token ...
2. 编辑文章和页面
有关编辑文章或页面词汇内容(包括小幅措辞修改和 URL 更改)的读取-编辑-写入工作流的详细说明,请参阅 editing.md 参考文档。
3. 搜索和筛选文章与页面
当您需要查找特定文章或页面时(例如,按标题、状态或标签),请参考 post.md 和 page.md 中记录的进阶筛选和 NQL 查询示例。
命令参考
每个资源的详细文档可以在 references/ 目录中找到:
管理页面和静态内容。 |
| ghst tag | 创建和管理站点标签。 |
| ghst member | 管理成员、导入、导出和批量操作。 |
| ghst socialweb | ActivityPub 订阅源、个人资料管理和社交互动。 |
| ghst comment | 审核、隐藏、显示和删除评论。 |
| ghst newsletter | 创建和管理新闻通讯及批量设置。 |
| ghst tier | 管理会员层级。 |
| ghst offer | 创建和管理订阅优惠。 |
| ghst stats | 站点分析、增长报告和文章流量。 |
| ghst setting | 检索和更新站点级设置。 |
| ghst image | 上传媒体资源到 Ghost。 |
| ghst theme | 上传、激活和验证站点主题。 |
| ghst label | 成员和内容的标签管理。 |
| ghst user | 管理员工用户和检索个人资料信息。 |
| ghst site | 常规站点信息。 |
| ghst webhook | 配置和监听 Ghost webhook。 |
| ghst migrate | WordPress、Medium、Substack 和 CSV 的导入工具。 |
| ghst auth | CLI 认证、站点切换和令牌管理。 |
| ghst config | CLI 工具配置和默认值。 |
| ghst api | 用于 Admin 和 Content API 的直接原始 API 浏览器。 |
示例工作流:
- * 批量文章标签:ghst post bulk --filter status:draft --update --add-tag Release
- 成员清理:ghst member bulk --filter status:free --action delete --yes --non-interactive
- 分析导出:ghst stats posts --range 30d --csv --output ./report.csv
- 社交互动:ghst socialweb note --content Hello from the CLI
4. 安全操作与保护
- - 批准与通知:在执行破坏性命令或批量更新之前,您必须明确询问用户。注意:当手动确认被中断时,CLI 会在 stderr 上发出 GHSTAGENTNOTICE: 行。如果您看到此信息,必须停止并向用户请求明确批准。
- 破坏性命令:一旦获得批准,始终对以下操作使用 --yes --non-interactive:
- ghst member bulk --action delete
- ghst label bulk --action delete
- ghst socialweb delete
- ghst auth logout
- ghst auth link(当替换活动链接时)
- - 文件安全:像 member export 和 migrate export 这样的 CLI 工具将拒绝覆盖现有文件。如有必要,在导出前检查文件是否存在。
- 安全检查:切勿在未提示的情况下将敏感令牌(例如来自 ghst auth token 或 config --show-secrets 的值)打印或输出到聊天中。将它们视为特权凭证。