Resolving gate-cli (binary path)
Resolve gate-cli in order: (1) command -v gate-cli and gate-cli --version succeeds; (2) ${HOME}/.local/bin/gate-cli if executable; (3) ${HOME}/.openclaw/skills/bin/gate-cli if executable. Canonical rules: exchange-runtime-rules.md §4 (or gate-runtime-rules.md §4).
Gate Exchange Sub-Account Skill
General Rules
⚠️ STOP — You MUST read and strictly follow the shared runtime rules before proceeding.
Do NOT select or call any tool until all rules are read. These rules have the highest priority.
→ Read gate-runtime-rules.md
- Only use the
gate-cli commands explicitly listed in this skill. Commands not documented here must NOT be run for these workflows, even if other interfaces expose them.
Skill Dependencies
gate-cli commands used
Query Operations (Read-only)
gate-cli cex sub-account get
gate-cli cex sub-account list
gate-cli cex sub-account lock
gate-cli cex sub-account unlock
Execution Operations (Write)
gate-cli cex sub-account create
Authentication
- Interactive file setup: when
GATE_API_KEY and GATE_API_SECRET are not both set on the host, run gate-cli config init to complete the wizard for API key, secret, profiles, and defaults (see gate-cli).
- Env / flags:
gate-cli config init is not required when credentials are already supplied — e.g. both GATE_API_KEY and GATE_API_SECRET set on the host, or --api-key / --api-secret where supported — never ask the user to paste secrets into chat.
- Permissions: Sa:Write
- Portal: create or rotate keys outside the chat: https://www.gate.com/myaccount/profile/api-key/manage
Installation Check
- Required:
gate-cli (run sh ./setup.sh from this skill directory if missing; optional GATE_CLI_SETUP_MODE=release).
- Add
$HOME/.openclaw/skills/bin to PATH if you invoke gate-cli by name (or the directory where setup.sh installs it).
- Credentials: When
GATE_API_KEY and GATE_API_SECRET are both set (non-empty) for the host, do not require gate-cli config init — that is equivalent valid config for gate-cli. When both are unset or empty, remind the operator to run gate-cli config init or to configure GATE_API_KEY / GATE_API_SECRET in the matching skill from the skill library (never ask the user to paste secrets into chat).
- Sanity check: Do not proceed with authenticated calls until the CLI behaves as expected (e.g.
gate-cli --version or a read-only gate-cli cex ... command from this skill); confirm credentials resolve before mutating operations.
Execution mode
Read and strictly follow references/gate-cli.md, then execute this skill's sub-account workflow.
SKILL.md keeps intent routing and permission boundaries.
references/gate-cli.md is the authoritative gate-cli execution contract for create/lock/unlock confirmation gates and status verification.
Prerequisites
- MCP Dependency: Requires gate-mcp to be installed.
- Authentication: All sub-account operations require API key authentication with main-account privileges.
- Permission: The current user must be a main account holder to manage sub-accounts.
Available MCP Tools
| Tool |
Auth |
Description |
gate-cli cex sub-account get |
Yes |
Get details of a specific sub-account by user ID |
gate-cli cex sub-account list |
Yes |
List all sub-accounts under the main account |
gate-cli cex sub-account create |
Yes |
Create a new normal sub-account |
gate-cli cex sub-account lock |
Yes |
Lock a sub-account to disable login and trading |
gate-cli cex sub-account unlock |
Yes |
Unlock a previously locked sub-account |
Workflow
Step 1: Identify User Intent
Parse the user's message to determine which sub-account operation they need.
Key data to extract:
intent: One of query_status, list_all, create, lock, unlock
user_id: Sub-account UID (required for query_status, lock, unlock)
login_name: Desired username (for create, may need to ask user)
Intent detection rules:
| Signal Keywords |
Intent |
| "status of sub-account", "sub-account UID {id}", "check sub-account" |
query_status |
| "all sub-accounts", "list sub-accounts", "my sub-accounts", "which sub-accounts" |
list_all |
| "create sub-account", "new sub-account", "add sub-account" |
create |
| "lock sub-account", "disable sub-account", "freeze sub-account" |
lock |
| "unlock sub-account", "enable sub-account", "unfreeze sub-account" |
unlock |
Step 2: Execute by Intent
Case A: Query Sub-Account Status (query_status)
Call gate-cli cex sub-account get with:
user_id: The sub-account UID provided by the user
Key data to extract:
login_name: Sub-account username
remark: Sub-account remark/note
state: Account state (normal / locked)
type: Account type (normal / pool)
create_time: Account creation timestamp
Present the sub-account details in a structured format.
Case B: List All Sub-Accounts (list_all)
Call gate-cli cex sub-account list with:
type: "0" (normal sub-accounts only)
Key data to extract:
- For each sub-account:
user_id, login_name, remark, state, create_time
Present results as a table with username, UID, remark (if any), and current status.
Case C: Create Sub-Account (create)
Pre-check: Call gate-cli cex sub-account list with type: "0" to get the current list of normal sub-accounts. Check if the user can still create more sub-accounts based on the returned count.
If creation is available:
- Ask the user to provide a login name for the new sub-account
- Optionally collect: email, remark
- Confirm all details with the user before proceeding
- Call
gate-cli cex sub-account create with:
login_name: User-provided login name (required)
email: User-provided email (optional)
remark: User-provided remark (optional)
- Present the newly created sub-account details
Key data to extract:
user_id: Newly created sub-account UID
login_name: Confirmed username
state: Should be "normal"
Important: Only normal sub-accounts can be created through this skill.
Case D: Lock Sub-Account (lock)
- Validate that
user_id is provided; if not, ask the user
- Call
gate-cli cex sub-account get with user_id to verify the sub-account exists and belongs to the main account
- If the sub-account is already locked, inform the user and stop
- Confirm with the user: "Are you sure you want to lock sub-account {user_id} ({login_name})? This will disable login and trading for this sub-account."
- On confirmation, call
gate-cli cex sub-account lock with:
user_id: The sub-account UID
- Report the result
Key data to extract:
- Lock operation success/failure status
Case E: Unlock Sub-Account (unlock)
- Validate that
user_id is provided; if not, ask the user
- Call
gate-cli cex sub-account get with user_id to verify the sub-account exists and is currently locked
- If the sub-account is already unlocked/normal, inform the user and stop
- Confirm with the user: "Are you sure you want to unlock sub-account {user_id} ({login_name})?"
- On confirmation, call
gate-cli cex sub-account unlock with:
user_id: The sub-account UID
- Report the result
Key data to extract:
- Unlock operation success/failure status
Step 3: Format and Respond
Present results using the Report Template below. Always include relevant context and next-step suggestions.
Judgment Logic Summary
| Condition |
Action |
| User asks for a specific sub-account status with UID |
Route to Case A: query_status |
| User asks to see all sub-accounts |
Route to Case B: list_all |
| User wants to create a new sub-account |
Route to Case C: create |
| User wants to lock a sub-account with UID |
Route to Case D: lock |
| User wants to unlock a sub-account with UID |
Route to Case E: unlock |
| UID not provided for operations requiring it |
Ask user for the sub-account UID |
| Login name not provided for creation |
Ask user for a login name |
| Sub-account already in target state (lock/unlock) |
Inform user, no action needed |
| API returns authentication error |
Prompt user to log in |
| API returns permission error |
Inform user that main account privileges are required |
| Sub-account does not exist or does not belong to user |
Inform user the UID is invalid |
Report Template
Query Status Response
Sub-Account Details
---
Username: {login_name}
UID: {user_id}
Status: {state}
Type: {type}
Remark: {remark or "N/A"}
Created: {create_time}
List All Sub-Accounts Response
Your Sub-Accounts
---
| # | Username | UID | Status | Remark |
|---|----------|-----|--------|--------|
| 1 | {login_name} | {user_id} | {state} | {remark or "-"} |
| 2 |... |... |... |... |
Total: {count} sub-account(s)
Create Sub-Account Response
Sub-Account Created Successfully
---
Username: {login_name}
UID: {user_id}
Status: Normal
Remark: {remark or "N/A"}
Note: Only normal sub-accounts can be created through this interface.
Lock/Unlock Response
Sub-Account {Action} Successfully
---
Username: {login_name}
UID: {user_id}
Previous Status: {previous_state}
Current Status: {new_state}
Domain Knowledge
- A main account on Gate can create multiple sub-accounts for asset isolation, strategy separation, or team management.
- Sub-accounts share the main account's KYC verification but have independent trading and wallet capabilities.
- Locking a sub-account disables both login and trading; the assets remain safe but inaccessible until unlocked.
- There are two types of sub-accounts: normal (type=0) and pool (type=1). This skill only supports creating normal sub-accounts.
- Sub-account creation requires a unique login name. Email and remark are optional.
Safety Rules
- Write operations (
gate-cli cex sub-account create, gate-cli cex sub-account lock, gate-cli cex sub-account unlock): Always require explicit user confirmation before execution. Never auto-execute.
- UID validation: Before lock/unlock, always verify the sub-account exists and belongs to the current main account.
- State check: Before lock/unlock, check current state to avoid redundant operations.
- No sensitive data exposure: Never expose API keys, internal endpoint URLs, or raw error traces.
- Normal sub-accounts only: Creation is restricted to normal sub-accounts (type=0). Do not attempt to create pool sub-accounts.
Error Handling
| Condition |
Response |
| Auth endpoint returns "not login" |
"Please log in to your Gate account first." |
| User is not a main account |
"Sub-account management requires main account privileges. Please switch to your main account." |
| Sub-account UID not found |
"Sub-account with UID {user_id} was not found. Please verify the UID and try again." |
| Sub-account does not belong to user |
"This sub-account does not belong to your main account." |
| Sub-account already locked |
"Sub-account {user_id} is already locked. No action needed." |
| Sub-account already unlocked |
"Sub-account {user_id} is already in normal (unlocked) state. No action needed." |
| Create sub-account fails (limit reached) |
"You have reached the maximum number of sub-accounts. Please contact support if you need more." |
| Create sub-account fails (duplicate name) |
"The login name '{login_name}' is already taken. Please choose a different name." |
| Unknown error |
"An error occurred while processing your request. Please try again later." |
Prompt Examples & Scenarios
See scenarios.md for full prompt examples and expected behaviors.
1---2name: gate-exchange-subaccount3description: "Gate Exchange sub-account management skill. Use when the user asks to manage, create, lock, unlock, or list their sub-accounts. Triggers on 'sub-account status', 'create sub-account', 'lock sub-account', 'my sub-accounts'."4user-invocable: true5disable-model-invocation: false6metadata:7 openclaw:8 emoji: "💱"9 os:10 - darwin11 - linux12 primaryEnv: GATE_API_KEY13 requires:14 bins:15 - gate-cli16 env:17 - GATE_API_KEY18 - GATE_API_SECRET1920 install:21 - kind: download22 os:23 - linux24 url: "https://github.com/gate/gate-cli/releases/download/v0.6.2/gate-cli_0.6.2_linux_amd64.tar.gz"25 bins:26 - gate-cli27 targetDir: "bin"28 label: "Download gate-cli (Linux x64)"29 - kind: download30 os:31 - linux32 url: "https://github.com/gate/gate-cli/releases/download/v0.6.2/gate-cli_0.6.2_linux_arm64.tar.gz"33 bins:34 - gate-cli35 targetDir: "bin"36 label: "Download gate-cli (Linux arm64)"37 - kind: download38 os:39 - darwin40 url: "https://github.com/gate/gate-cli/releases/download/v0.6.2/gate-cli_0.6.2_darwin_amd64.tar.gz"41 bins:42 - gate-cli43 targetDir: "bin"44 label: "Download gate-cli (macOS Intel)"45 - kind: download46 os:47 - darwin48 url: "https://github.com/gate/gate-cli/releases/download/v0.6.2/gate-cli_0.6.2_darwin_arm64.tar.gz"49 bins:50 - gate-cli51 targetDir: "bin"52 label: "Download gate-cli (macOS Apple Silicon)"53---5455### Resolving `gate-cli` (binary path)5657Resolve **`gate-cli`** in order: **(1)** **`command -v gate-cli`** and **`gate-cli --version`** succeeds; **(2)** **`${HOME}/.local/bin/gate-cli`** if executable; **(3)** **`${HOME}/.openclaw/skills/bin/gate-cli`** if executable. Canonical rules: [`exchange-runtime-rules.md`](https://github.com/gate/gate-skills/blob/master/skills/exchange-runtime-rules.md) §4 (or [`gate-runtime-rules.md`](https://github.com/gate/gate-skills/blob/master/skills/gate-runtime-rules.md) §4).585960# Gate Exchange Sub-Account Skill6162## General Rules6364⚠️ STOP — You MUST read and strictly follow the shared runtime rules before proceeding.65Do NOT select or call any tool until all rules are read. These rules have the highest priority.66→ Read [gate-runtime-rules.md](https://github.com/gate/gate-skills/blob/master/skills/gate-runtime-rules.md)67- **Only use the `gate-cli` commands explicitly listed in this skill.** Commands not documented here must NOT be run for these workflows, even if other interfaces expose them.6869## Skill Dependencies707172### gate-cli commands used7374**Query Operations (Read-only)**7576- `gate-cli cex sub-account get`77- `gate-cli cex sub-account list`78- `gate-cli cex sub-account lock`79- `gate-cli cex sub-account unlock`8081**Execution Operations (Write)**8283- `gate-cli cex sub-account create`8485### Authentication86- **Interactive file setup:** when **`GATE_API_KEY`** and **`GATE_API_SECRET`** are **not** both set on the host, run **`gate-cli config init`** to complete the wizard for API key, secret, profiles, and defaults (see [gate-cli](https://github.com/gate/gate-cli)).87- **Env / flags:** **`gate-cli config init`** is **not** required when credentials are already supplied — e.g. **both** **`GATE_API_KEY`** and **`GATE_API_SECRET`** set on the host, or **`--api-key`** / **`--api-secret`** where supported — never ask the user to paste secrets into chat.88- **Permissions:** Sa:Write89- **Portal:** create or rotate keys outside the chat: https://www.gate.com/myaccount/profile/api-key/manage9091### Installation Check92- **Required:** `gate-cli` (run `sh ./setup.sh` from this skill directory if missing; optional `GATE_CLI_SETUP_MODE=release`).93- Add `$HOME/.openclaw/skills/bin` to **`PATH`** if you invoke `gate-cli` by name (or the directory where [`setup.sh`](./setup.sh) installs it).94- **Credentials:** When **`GATE_API_KEY`** and **`GATE_API_SECRET`** are both set (non-empty) for the host, **do not** require **`gate-cli config init`** — that is equivalent valid config for `gate-cli`. When **both** are unset or empty, **remind** the operator to run **`gate-cli config init`** **or** to configure **`GATE_API_KEY`** / **`GATE_API_SECRET`** in the **matching skill** from the skill library (never ask the user to paste secrets into chat).95- **Sanity check:** Do not proceed with authenticated calls until the CLI behaves as expected (e.g. **`gate-cli --version`** or a read-only **`gate-cli cex ...`** command from this skill); confirm credentials resolve before mutating operations.9697## Execution mode9899**Read and strictly follow** [`references/gate-cli.md`](./references/gate-cli.md), then execute this skill's sub-account workflow.100101- `SKILL.md` keeps intent routing and permission boundaries.102- `references/gate-cli.md` is the authoritative `gate-cli` execution contract for create/lock/unlock confirmation gates and status verification.103104## Prerequisites105106- **MCP Dependency**: Requires [gate-mcp](https://github.com/gate/gate-mcp) to be installed.107- **Authentication**: All sub-account operations require API key authentication with main-account privileges.108- **Permission**: The current user must be a main account holder to manage sub-accounts.109110## Available MCP Tools111112| Tool | Auth | Description |113|------|------|-------------|114| `gate-cli cex sub-account get` | Yes | Get details of a specific sub-account by user ID |115| `gate-cli cex sub-account list` | Yes | List all sub-accounts under the main account |116| `gate-cli cex sub-account create` | Yes | Create a new normal sub-account |117| `gate-cli cex sub-account lock` | Yes | Lock a sub-account to disable login and trading |118| `gate-cli cex sub-account unlock` | Yes | Unlock a previously locked sub-account |119120## Workflow121122### Step 1: Identify User Intent123124Parse the user's message to determine which sub-account operation they need.125126Key data to extract:127- `intent`: One of `query_status`, `list_all`, `create`, `lock`, `unlock`128- `user_id`: Sub-account UID (required for `query_status`, `lock`, `unlock`)129- `login_name`: Desired username (for `create`, may need to ask user)130131Intent detection rules:132133| Signal Keywords | Intent |134|----------------|--------|135| "status of sub-account", "sub-account UID {id}", "check sub-account" | `query_status` |136| "all sub-accounts", "list sub-accounts", "my sub-accounts", "which sub-accounts" | `list_all` |137| "create sub-account", "new sub-account", "add sub-account" | `create` |138| "lock sub-account", "disable sub-account", "freeze sub-account" | `lock` |139| "unlock sub-account", "enable sub-account", "unfreeze sub-account" | `unlock` |140141### Step 2: Execute by Intent142143#### Case A: Query Sub-Account Status (`query_status`)144145Call `gate-cli cex sub-account get` with:146- `user_id`: The sub-account UID provided by the user147148Key data to extract:149- `login_name`: Sub-account username150- `remark`: Sub-account remark/note151- `state`: Account state (normal / locked)152- `type`: Account type (normal / pool)153- `create_time`: Account creation timestamp154155Present the sub-account details in a structured format.156157#### Case B: List All Sub-Accounts (`list_all`)158159Call `gate-cli cex sub-account list` with:160- `type`: "0" (normal sub-accounts only)161162Key data to extract:163- For each sub-account: `user_id`, `login_name`, `remark`, `state`, `create_time`164165Present results as a table with username, UID, remark (if any), and current status.166167#### Case C: Create Sub-Account (`create`)168169**Pre-check**: Call `gate-cli cex sub-account list` with `type`: "0" to get the current list of normal sub-accounts. Check if the user can still create more sub-accounts based on the returned count.170171If creation is available:1721. Ask the user to provide a login name for the new sub-account1732. Optionally collect: email, remark1743. Confirm all details with the user before proceeding1754. Call `gate-cli cex sub-account create` with:176 - `login_name`: User-provided login name (required)177 - `email`: User-provided email (optional)178 - `remark`: User-provided remark (optional)1795. Present the newly created sub-account details180181Key data to extract:182- `user_id`: Newly created sub-account UID183- `login_name`: Confirmed username184- `state`: Should be "normal"185186**Important**: Only normal sub-accounts can be created through this skill.187188#### Case D: Lock Sub-Account (`lock`)1891901. Validate that `user_id` is provided; if not, ask the user1912. Call `gate-cli cex sub-account get` with `user_id` to verify the sub-account exists and belongs to the main account1923. If the sub-account is already locked, inform the user and stop1934. Confirm with the user: "Are you sure you want to lock sub-account {user_id} ({login_name})? This will disable login and trading for this sub-account."1945. On confirmation, call `gate-cli cex sub-account lock` with:195 - `user_id`: The sub-account UID1966. Report the result197198Key data to extract:199- Lock operation success/failure status200201#### Case E: Unlock Sub-Account (`unlock`)2022031. Validate that `user_id` is provided; if not, ask the user2042. Call `gate-cli cex sub-account get` with `user_id` to verify the sub-account exists and is currently locked2053. If the sub-account is already unlocked/normal, inform the user and stop2064. Confirm with the user: "Are you sure you want to unlock sub-account {user_id} ({login_name})?"2075. On confirmation, call `gate-cli cex sub-account unlock` with:208 - `user_id`: The sub-account UID2096. Report the result210211Key data to extract:212- Unlock operation success/failure status213214### Step 3: Format and Respond215216Present results using the Report Template below. Always include relevant context and next-step suggestions.217218## Judgment Logic Summary219220| Condition | Action |221|-----------|--------|222| User asks for a specific sub-account status with UID | Route to Case A: `query_status` |223| User asks to see all sub-accounts | Route to Case B: `list_all` |224| User wants to create a new sub-account | Route to Case C: `create` |225| User wants to lock a sub-account with UID | Route to Case D: `lock` |226| User wants to unlock a sub-account with UID | Route to Case E: `unlock` |227| UID not provided for operations requiring it | Ask user for the sub-account UID |228| Login name not provided for creation | Ask user for a login name |229| Sub-account already in target state (lock/unlock) | Inform user, no action needed |230| API returns authentication error | Prompt user to log in |231| API returns permission error | Inform user that main account privileges are required |232| Sub-account does not exist or does not belong to user | Inform user the UID is invalid |233234## Report Template235236### Query Status Response237238```239Sub-Account Details240---241Username: {login_name}242UID: {user_id}243Status: {state}244Type: {type}245Remark: {remark or "N/A"}246Created: {create_time}247```248249### List All Sub-Accounts Response250251```252Your Sub-Accounts253---254| # | Username | UID | Status | Remark |255|---|----------|-----|--------|--------|256| 1 | {login_name} | {user_id} | {state} | {remark or "-"} |257| 2 |... |... |... |... |258259Total: {count} sub-account(s)260```261262### Create Sub-Account Response263264```265Sub-Account Created Successfully266---267Username: {login_name}268UID: {user_id}269Status: Normal270Remark: {remark or "N/A"}271272Note: Only normal sub-accounts can be created through this interface.273```274275### Lock/Unlock Response276277```278Sub-Account {Action} Successfully279---280Username: {login_name}281UID: {user_id}282Previous Status: {previous_state}283Current Status: {new_state}284```285286## Domain Knowledge287288- A main account on Gate can create multiple sub-accounts for asset isolation, strategy separation, or team management.289- Sub-accounts share the main account's KYC verification but have independent trading and wallet capabilities.290- Locking a sub-account disables both login and trading; the assets remain safe but inaccessible until unlocked.291- There are two types of sub-accounts: normal (type=0) and pool (type=1). This skill only supports creating normal sub-accounts.292- Sub-account creation requires a unique login name. Email and remark are optional.293294## Safety Rules295296- **Write operations** (`gate-cli cex sub-account create`, `gate-cli cex sub-account lock`, `gate-cli cex sub-account unlock`): Always require explicit user confirmation before execution. Never auto-execute.297- **UID validation**: Before lock/unlock, always verify the sub-account exists and belongs to the current main account.298- **State check**: Before lock/unlock, check current state to avoid redundant operations.299- **No sensitive data exposure**: Never expose API keys, internal endpoint URLs, or raw error traces.300- **Normal sub-accounts only**: Creation is restricted to normal sub-accounts (type=0). Do not attempt to create pool sub-accounts.301302## Error Handling303304| Condition | Response |305|-----------|----------|306| Auth endpoint returns "not login" | "Please log in to your Gate account first." |307| User is not a main account | "Sub-account management requires main account privileges. Please switch to your main account." |308| Sub-account UID not found | "Sub-account with UID {user_id} was not found. Please verify the UID and try again." |309| Sub-account does not belong to user | "This sub-account does not belong to your main account." |310| Sub-account already locked | "Sub-account {user_id} is already locked. No action needed." |311| Sub-account already unlocked | "Sub-account {user_id} is already in normal (unlocked) state. No action needed." |312| Create sub-account fails (limit reached) | "You have reached the maximum number of sub-accounts. Please contact support if you need more." |313| Create sub-account fails (duplicate name) | "The login name '{login_name}' is already taken. Please choose a different name." |314| Unknown error | "An error occurred while processing your request. Please try again later." |315316## Prompt Examples & Scenarios317318See [scenarios.md](references/scenarios.md) for full prompt examples and expected behaviors.