holded-skill
Use holdedcli to read and modify Holded data with a safe, repeatable workflow.
Operational Flow
- 1. Confirm technical prerequisites.
- Discover available actions with
holded actions list. - Inspect the selected action with
holded actions describe <action> --json. - Classify the action as read or write.
- If it is a write operation, ask for explicit confirmation before execution.
- Run with
--json and summarize IDs, HTTP status, and applied changes.
Prerequisites
- - Verify that the binary exists: INLINECODE4
- Verify credentials:
holded auth status or INLINECODE6 - Prefer structured output whenever possible: INLINECODE7
Safety Rules
- - ALWAYS check deductibility rules BEFORE creating any document. See "Accounting Rules for Spain" section below.
- Treat any
POST, PUT, PATCH, or DELETE action as write. - Treat any
GET action (or HEAD when present) as read. - Before any operation, always run
holded actions describe <action> --json (after holded actions list) to validate accepted parameters. - For purchase receipts, always enforce
docType=purchase and include "isReceipt": true in the JSON body. Since holdedcli validates against Holded's schema (which doesn't include isReceipt), you must use --skip-validation flag. - Ask for explicit user confirmation every time before any write action.
- Do not execute writes on ambiguous replies (
ok, go ahead, continue) without clarification. - Repeat the exact command before confirmation to avoid unintended changes.
- If the user does not confirm, stop and offer payload adjustments.
Mandatory Confirmation Protocol
Before any write action, show:
- 1. Holded action (
action_id or operation_id). - Method and endpoint.
- INLINECODE25 ,
--query, and body parameters (--body or --body-file). - The exact command to run.
Use this format:
CODEBLOCK0
Execute only after an explicit affirmative response.
Execution Pattern
Read Operations
- 1. Locate the action with
holded actions list --json (use --filter). - Verify accepted path/query/body parameters with
holded actions describe <action> --json. - Run
holded actions run <action> ... --json. - Return a clear summary and relevant IDs for follow-up steps.
Write Operations
- 1. Locate and validate the action.
- Run
holded actions describe <action> --json to verify required/optional parameters. - Prepare the final payload.
- If creating a purchase receipt/ticket, verify
docType=purchase and "isReceipt": true, and use --skip-validation flag. - Request mandatory confirmation.
- Run the command after confirmation.
- Report result (
status_code, affected ID, API response).
Base Commands
CODEBLOCK1
For long payloads, prefer --body-file:
CODEBLOCK2
Purchase receipt rule (mandatory for purchase tickets):
CODEBLOCK3
Important notes:
- - Use
--skip-validation flag because holdedcli validates against Holded's schema which doesn't include isReceipt. - Use
subtotal in items (not price) - this is the field name Holded's API expects. - Timestamps must be in seconds (Unix epoch) and in Europe/Madrid timezone.
Timestamp calculation (Python):
CODEBLOCK4
Accounting Rules for Spain
⚠️ ALWAYS check these rules BEFORE creating any expense document:
| Expense Type | IVA Deductible | Expense Deductible | Account |
|---|
| Restaurants/Meals | ❌ No | ✅ Yes (with justification) | 629 |
| Displacement |
❌ No | ✅ Yes | 629 |
| Fuel | ⚠️ Mixed | ✅ Yes | 625/622 |
| Office supplies | ✅ Yes | ✅ Yes | 600/602 |
| Insurance | ⚠️ Mixed | ✅ Yes | 625 |
Before creating any document, ALWAYS verify:
- 1. Is the expense tax deductible?
- Is the IVA deductible? (usually NO for restaurants, displacement)
- If in doubt, ASK before creating the document.
Common mistake to avoid: Never set tax: 10 or tax: 21 for restaurant expenses - IVA is NOT deductible for meals unless it's a business event with proper justification.
Error Handling
- - If
MISSING_API_KEY appears, configure API key through --api-key, HOLDED_API_KEY, or holded auth set. - If
ACTION_NOT_FOUND appears, list the catalog and search with --filter. - If
INVALID_BODY appears, validate JSON before execution. - If
API_ERROR appears, report status_code and the API snippet.
References
- - Read
{baseDir}/references/holdedcli-reference.md for quick commands and criteria. - Use dynamic action discovery and parameter inspection via:
-
holded actions list --json
- INLINECODE56
holded-skill
使用 holdedcli 以安全、可重复的工作流程读取和修改 Holded 数据。
操作流程
- 1. 确认技术前提条件。
- 使用 holded actions list 发现可用操作。
- 使用 holded actions describe --json 检查所选操作。
- 将操作分类为读取或写入。
- 如果是写入操作,在执行前请求明确确认。
- 使用 --json 运行,并汇总 ID、HTTP 状态和应用的更改。
前提条件
- - 验证二进制文件存在:holded help
- 验证凭据:holded auth status 或 HOLDEDAPIKEY
- 尽可能使用结构化输出:--json
安全规则
- - 在创建任何文档之前,务必检查可扣除性规则。 请参阅下方西班牙会计规则部分。
- 将任何 POST、PUT、PATCH 或 DELETE 操作视为写入。
- 将任何 GET 操作(或存在的 HEAD)视为读取。
- 在任何操作之前,始终先运行 holded actions list,然后运行 holded actions describe --json 以验证接受的参数。
- 对于采购收据,始终强制使用 docType=purchase,并在 JSON 正文中包含 isReceipt: true。由于 holdedcli 会根据 Holded 的模式进行验证(该模式不包含 isReceipt),您必须使用 --skip-validation 标志。
- 每次执行任何写入操作前,请求明确的用户确认。
- 对于模棱两可的回复(ok、go ahead、continue),未经澄清不得执行写入操作。
- 在确认前重复确切的命令,以避免意外更改。
- 如果用户未确认,则停止并提供负载调整。
强制确认协议
在任何写入操作之前,显示:
- 1. Holded 操作(actionid 或 operationid)。
- 方法和端点。
- --path、--query 和正文参数(--body 或 --body-file)。
- 要运行的确切命令。
使用以下格式:
text
此操作将修改 Holded 中的数据。
操作:( )
更改:<简短摘要>
命令:holded actions run ... --json
您确认我应该运行此确切命令吗?(回复yes或confirm)
仅在收到明确的肯定回复后执行。
执行模式
读取操作
- 1. 使用 holded actions list --json 定位操作(使用 --filter)。
- 使用 holded actions describe --json 验证接受的路径/查询/正文参数。
- 运行 holded actions run ... --json。
- 返回清晰的摘要和用于后续步骤的相关 ID。
写入操作
- 1. 定位并验证操作。
- 运行 holded actions describe --json 以验证必需/可选参数。
- 准备最终负载。
- 如果创建采购收据/票据,验证 docType=purchase 和 isReceipt: true,并使用 --skip-validation 标志。
- 请求强制确认。
- 确认后运行命令。
- 报告结果(status_code、受影响的 ID、API 响应)。
基本命令
bash
holded auth set --api-key $HOLDEDAPIKEY
holded auth status
holded ping --json
holded actions list --json
holded actions list --filter contacts --json
holded actions describe invoice.get-contact --json
holded actions run invoice.get-contact --path contactId= --json
对于长负载,优先使用 --body-file:
bash
holded actions run invoice.update-contact \
--path contactId= \
--body-file payload.json \
--json
采购收据规则(采购票据必需):
bash
holded actions describe invoice.create-document --json
holded actions run invoice.create-document \
--path docType=purchase \
--body {isReceipt: true, date: 1770764400, contactId: , items: [{name: Description, units: 1, subtotal: 29.4, tax: 0}]} \
--skip-validation \
--json
重要说明:
- - 使用 --skip-validation 标志,因为 holdedcli 会根据 Holded 的模式进行验证,该模式不包含 isReceipt。
- 在项目中使用 subtotal(而非 price)——这是 Holded API 期望的字段名称。
- 时间戳必须以秒为单位(Unix 纪元),并且使用欧洲/马德里时区。
时间戳计算(Python):
python
from datetime import datetime, timezone, timedelta
马德里时间 2026 年 2 月 11 日 00:00:
dt = datetime(2026, 2, 11, 0, 0, 0, tzinfo=timezone(timedelta(hours=1)))
print(int(dt.timestamp())) # 1770764400
西班牙会计规则
⚠️ 在创建任何费用文档之前,务必检查这些规则:
| 费用类型 | IVA 可扣除 | 费用可扣除 | 账户 |
|---|
| 餐厅/餐饮 | ❌ 否 | ✅ 是(需有正当理由) | 629 |
| 差旅费 |
❌ 否 | ✅ 是 | 629 |
| 燃油费 | ⚠️ 混合 | ✅ 是 | 625/622 |
| 办公用品 | ✅ 是 | ✅ 是 | 600/602 |
| 保险费 | ⚠️ 混合 | ✅ 是 | 625 |
在创建任何文档之前,务必验证:
- 1. 该费用是否可税前扣除?
- IVA 是否可扣除?(对于餐厅、差旅费通常为否)
- 如有疑问,在创建文档前询问。
要避免的常见错误: 切勿为餐厅费用设置 tax: 10 或 tax: 21——除非是经过适当证明的商业活动,否则餐饮费用的 IVA 不可扣除。
错误处理
- - 如果出现 MISSINGAPIKEY,通过 --api-key、HOLDEDAPIKEY 或 holded auth set 配置 API 密钥。
- 如果出现 ACTIONNOTFOUND,列出目录并使用 --filter 搜索。
- 如果出现 INVALIDBODY,在执行前验证 JSON。
- 如果出现 APIERROR,报告 status_code 和 API 片段。
参考资料
- - 阅读 {baseDir}/references/holdedcli-reference.md 以获取快速命令和标准。
- 通过以下方式使用动态操作发现和参数检查:
- holded actions list --json
- holded actions describe
--json