Ledgi CLI Skill
You can interact with the user's Ledgi personal finance tracker using the ledgi CLI. All financial data is accessed through the Ledgi Agent API.
Prerequisites
- - The
ledgi CLI must be installed. If not, install with:
curl -fsSL https://raw.githubusercontent.com/LedgiApp/ledgi-cli/main/install.sh | bash
- - The
LEDGI_API_KEY environment variable must be set, or the user must have run INLINECODE3
If a command fails with an auth error, ask the user to set their API key.
Core workflows
Read financial data
CODEBLOCK1
All commands return JSON by default. Use --output table for human-readable output when displaying to the user.
Create or update accounts
For a single account:
CODEBLOCK2
For multiple accounts, write a JSON file then bulk-upsert:
CODEBLOCK3
See schemas.md for JSON file formats.
Create or update holdings
Write a JSON file then bulk-upsert:
CODEBLOCK4
Take a net worth snapshot
CODEBLOCK5
Log an ISA deposit
CODEBLOCK6
Valid account types
Use these exact values for the --type flag:
- - Cash:
cash, current, savings, INLINECODE9 - ISA:
isa_cash, isa_stocks, isa_lifetime, INLINECODE13 - Pension:
pension, pension_workplace, pension_sipp, INLINECODE17 - Investment:
investment, INLINECODE19 - Property: INLINECODE20
- Debt:
credit_card, loan, mortgage, INLINECODE24 - Other:
other_asset, INLINECODE26
Error handling
- - 401 Unauthorized: API key is missing or invalid. Ask the user to check their key.
- 403 Forbidden: The API key doesn't have the required scope. Tell the user which scope is needed.
- 404 Not Found: The referenced resource doesn't exist.
- 422 Validation Error: Invalid input. Check the account type or required fields.
Important notes
- - Always use
--output table when showing results to the user for readability. - When creating accounts, include
--external-id for idempotency so re-running won't create duplicates. - Monetary values are in the account's currency (default GBP).
- The
--date flag uses YYYY-MM-DD format.
For full command reference, see commands.md.
For JSON file schemas, see schemas.md.
技能名称: ledgi
详细描述:
Ledgi CLI 技能
你可以使用 ledgi CLI 与用户的 Ledgi 个人财务追踪器进行交互。所有财务数据均通过 Ledgi Agent API 访问。
前置条件
- - 必须安装 ledgi CLI。若未安装,请使用以下命令安装:
bash
curl -fsSL https://raw.githubusercontent.com/LedgiApp/ledgi-cli/main/install.sh | bash
- - 必须设置 LEDGIAPIKEY 环境变量,或用户已运行 ledgi login --api-key ledgisk...
如果命令因认证错误失败,请要求用户设置其 API 密钥。
核心工作流程
读取财务数据
bash
ledgi accounts list # 所有账户
ledgi accounts list --type isa_stocks # 按类型筛选
ledgi holdings list # 所有投资持仓
ledgi holdings list --account-id ID # 单个账户中的持仓
ledgi networth summary # 净资产明细
ledgi snapshots list # 历史快照
ledgi isa summary # ISA 免税额度和使用情况
所有命令默认返回 JSON 格式。向用户展示时,请使用 --output table 参数以获取人类可读的输出。
创建或更新账户
单个账户:
bash
ledgi accounts upsert --name Monzo Current --type current --balance 2500 --currency GBP --institution Monzo
多个账户:先编写 JSON 文件,然后批量更新:
bash
ledgi accounts bulk-upsert --file /tmp/accounts.json
JSON 文件格式请参见 schemas.md。
创建或更新持仓
先编写 JSON 文件,然后批量更新:
bash
ledgi holdings bulk-upsert --file /tmp/holdings.json
创建净资产快照
bash
ledgi snapshots create
ledgi snapshots create --date 2026-01-31
记录 ISA 存款
bash
ledgi isa deposit --account-id ACCOUNT_ID --amount 5000 --date 2026-02-24
有效的账户类型
请使用以下精确值作为 --type 参数:
- - 现金类:cash、current、savings、premiumbonds
- ISA 类:isacash、isastocks、isalifetime、isainnovative
- 养老金类:pension、pensionworkplace、pensionsipp、pensionstate
- 投资类:investment、cryptowallet
- 房产类:property
- 债务类:creditcard、loan、mortgage、studentloan
- 其他类:otherasset、other_liability
错误处理
- - 401 未授权:API 密钥缺失或无效。请要求用户检查其密钥。
- 403 禁止访问:API 密钥没有所需的作用域。告知用户需要哪个作用域。
- 404 未找到:引用的资源不存在。
- 422 验证错误:输入无效。请检查账户类型或必填字段。
重要说明
- - 向用户展示结果时,始终使用 --output table 参数以确保可读性。
- 创建账户时,请包含 --external-id 参数以实现幂等性,避免重复运行创建重复账户。
- 货币值以账户的货币单位为准(默认为 GBP)。
- --date 参数使用 YYYY-MM-DD 格式。
完整命令参考请参见 commands.md。
JSON 文件模式请参见 schemas.md。