This skill guides you on how to operate ZenTao resources through zentao-cli, as well as what precautions to take.
Configuration initialization
Automatic configuration bootstrapping process
When the user has not configured or authentication fails:
-
Detect configuration status
zentao-cli auth statusIf it returns
ZEN_AUTH_FAILEDorZEN_CONFIG_INVALID, it means it is not configured or the configuration is invalid. -
Ask the user for configuration information and save location
You must explicitly ask for the save location: global or current project?
Ask the user for the following:
- ZenTao service address (for example
http://172.168.80.30:8001/zentao) - ZenTao account
- ZenTao password
- Save location: global (
~/.zentao-cli/config.toml) or current project (.zentao-cli/config.toml)?
⚠️ Important: You must wait for the user to explicitly answer the save location before executing the configuration command. It is forbidden to default to global configuration when the user has not chosen.
-
Execute configuration
Global save:
zentao-cli config set -g url "用户提供的地址" zentao-cli auth login -g --account 账号 --password 密码Current project save:
zentao-cli config set url "用户提供的地址" zentao-cli auth login --account 账号 --password 密码Note:
config setonly supportsurl、token、product_id、project_id, and does not support directly setting the account and password. It must be done in two steps: first set the URL, then useauth loginto obtain a token via the account and password. -
Verify that configuration succeeded
zentao-cli auth status
Quick check
# 检查认证状态
zentao-cli auth status
# 验证配置
echo $ZENTAO_URL
echo $ZENTAO_TOKEN
Obtain Token (manual)
- Log in to the ZenTao Web interface
- Go to Personal Settings → API Token
- Generate a new Token
- Set it as the
ZENTAO_TOKENenvironment variable
Environment variable description
| Variable | Required | Description |
|---|---|---|
ZENTAO_URL |
Yes | ZenTao server address, for example https://zentao.example.com |
ZENTAO_TOKEN |
Yes | API Token, used for authentication |
ZENTAO_PRODUCT_ID |
No | Default product ID |
ZENTAO_PROJECT_ID |
No | Default project ID |
Authentication
Token-based authentication
ZenTao uses Token for authentication, and the Token is passed through the ZENTAO_TOKEN environment variable.
# 验证认证状态
zentao-cli auth status
Error response format:
{
"status": "error",
"error": {
"code": "ZEN_AUTH_FAILED",
"message": "Invalid token or token expired",
"hint": "Verify ZENTAO_TOKEN is correct"
}
}
Common error codes
| Code | Description | Resolution |
|---|---|---|
ZEN_AUTH_FAILED |
Token is invalid or expired | Verify whether ZENTAO_TOKEN is correct |
ZEN_NOT_FOUND |
Resource does not exist | Check the ID and retry |
ZEN_CONFIG_INVALID |
Configuration is invalid | Verify ZENTAO_URL and ZENTAO_TOKEN |
ZEN_API_ERROR |
ZenTao API returned an error | Check the server status or retry later |
ZEN_PARAM_MISSING |
Missing required parameters | Provide all required parameters |
Handling insufficient permissions
When encountering permission-related errors:
- Confirm the current user role (in ZenTao this is usually
admin、leaderormember) - Verify whether the Token has the permissions required to operate on that resource
- If it is an administrator, check whether the user has been correctly assigned to the relevant project/product
Configuration priority
CLI parameter priority from highest to lowest:
- Command-line parameters(
--product,--project, etc.) - Environment variables(
ZENTAO_PRODUCT_ID,ZENTAO_PROJECT_ID) - Default configuration
# 命令行参数优先级最高
zentao-cli task list --project 5 # 使用 --project 参数
# 环境变量作为默认值
export ZENTAO_PROJECT_ID=5
zentao-cli task list # 使用环境变量
# 默认值兜底
zentao-cli task list # 使用配置中的默认值
General options
| Option | Description |
|---|---|
--format |
Output format:json、pretty、table、ndjson、csv |
--product |
Filter by product ID |
--project |
Filter by project ID |
--status |
Filter by status |
Output format
# JSON 输出(默认,用于脚本)
zentao-cli story list --product 1 --format json
# Pretty 打印输出(默认,用于终端)
zentao-cli story list --product 1 --format pretty
# 表格输出
zentao-cli story list --product 1 --format table
Update check
After executing the zentao-cli command, if a new version is detected, the JSON output will include the _notice.update field (including message、command , etc.).
When you see _notice.update in the output, after completing the current request, additionally inform and propose an update:
- Inform of the current version and latest version number
- Propose executing:
npm update -g zentao-cli && npx skills add zentao/cli -g -y - Remind the user to exit and reopen the AI Agent to load the latest Skills
Rule: Do not silently ignore update prompts. Even if the current task is unrelated to updates, you should additionally inform the user after completing their request.
Security rules
- Do not output secret keys(token, appSecret) to the terminal in plaintext.
- Confirm user intent before write/delete operations。
- Use
--dry-runto preview dangerous requests.