Zerodha
Route natural-language trading/account queries to the correct `zerodha` CLI command with exact flags, validation constraints, and synonym mapping. Use when a...
技能说明
name: zerodha-kite-cli-router
description: Route natural-language trading/account queries to the correct zerodha CLI command with exact flags, validation constraints, and synonym mapping. Use when a user asks to view prices, place/modify/cancel orders, manage auth/profile/config, work with holdings/positions/margins/GTT/MF flows, or asks "which zerodha command should I run?"
Purpose
Translate a user query in plain English into one exact zerodha CLI command.
Do not invent commands or flags. Use only commands defined here.
Bootstrap: CLI Installation
If the user asks to install/setup the CLI, or reports zerodha: command not found, route to an installer command first.
This is the only exception to "commands must start with zerodha".
Install commands:
- Linux/macOS (
curl):curl -fsSL https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.sh | sh - Linux/macOS (
wget):wget -qO- https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.sh | sh - Windows PowerShell:
irm https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.ps1 | iex - Windows CMD:
powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.ps1 | iex"
Post-install verification command:
zerodha version
Global Rules
- Always start commands with
zerodha(except install/bootstrap commands in "Bootstrap: CLI Installation"). - Prefer
--jsonwhen the user asks for machine-readable output. - Respect global flags when provided:
--profile <name>--config <path>--json--debug
- Profile selection:
- Most commands require an active profile (or explicit
--profile). - If no profile is selected, use:
zerodha config profile use <name>
- Most commands require an active profile (or explicit
- Auth/session:
- API data/order commands require an access token.
- If missing, run
zerodha auth login .... - CLI auto-refreshes access token when refresh token exists.
- Never guess missing required fields for write actions; ask for the missing values.
- If OS is required for installation routing and missing, ask for only the OS (
linux,macos, orwindows).
Login Flow (Multi-Message)
Use this flow when the user wants to authenticate and provides api_key, api_secret, and token across one or more messages.
Collected auth fields (can arrive in any order):
profile_name(default todefaultif user does not specify)api_keyapi_secret- one login mode:
request_token_or_redirect_url, orcallback(optionalcallback_port)
Rules:
- Persist auth fields provided in earlier user messages during the same login task.
- Ask only for missing required auth inputs for the next step.
- Do not emit
zerodha auth login ...until profile credentials are configured. - If
api_key+api_secretare available and profile setup is needed, emit:zerodha config profile add <profile_name> --api-key <key> --api-secret <secret> --set-active - If user explicitly wants to update only one credential on an existing profile, emit:
zerodha config profile set-api-key <profile_name> --api-key <key>zerodha config profile set-api-secret <profile_name> --api-secret <secret>
- For token mode, emit:
zerodha auth login --request-token <token_or_redirect_url> - For callback mode, emit:
zerodha auth login --callback [--callback-port <1-65535>] - If multiple commands are needed, output only the next runnable command.
Command Catalog
Root utilities
zerodha versionzerodha help [command]zerodha completion <shell>
Config profile
zerodha config profile add <name> --api-key <key> --api-secret <secret> [--set-active]- Constraints:
<name>required;--api-keyand--api-secretrequired.
- Constraints:
zerodha config profile set-api-key <name> --api-key <key>- Constraints:
<name>,--api-keyrequired.
- Constraints:
zerodha config profile set-api-secret <name> --api-secret <secret>- Constraints:
<name>,--api-secretrequired.
- Constraints:
zerodha config profile listzerodha config profile use <name>- Constraints:
<name>must exist.
- Constraints:
zerodha config profile remove <name>- Constraints:
<name>must exist.
- Constraints:
Auth
zerodha auth login --request-token <token_or_redirect_url>zerodha auth login --callback [--callback-port <1-65535>]- Constraints:
- Exactly one mode is required:
--request-tokenOR--callback. --request-tokencannot be combined with--callback.--callback-portallowed only with--callback.--callback-portrange:1..65535.
- Exactly one mode is required:
- Constraints:
zerodha auth renew- Constraints: refresh token must exist in profile.
zerodha auth logoutzerodha auth revoke-refresh [--refresh-token <token>]- If omitted, uses stored refresh token.
Profile
zerodha profile showzerodha profile full
Quotes
zerodha quote get <EXCHANGE:SYMBOL> [EXCHANGE:SYMBOL...]- Constraints: at least 1 instrument.
zerodha quote ltp <EXCHANGE:SYMBOL> [EXCHANGE:SYMBOL...]- Constraints: at least 1 instrument.
zerodha quote ohlc <EXCHANGE:SYMBOL> [EXCHANGE:SYMBOL...]- Constraints: at least 1 instrument.
zerodha quote historical --instrument-token <int> --interval <value> --from <time> --to <time> [--continuous] [--oi]- Constraints:
--instrument-token > 0--intervalrequired--fromand--torequired- time format:
YYYY-MM-DDorYYYY-MM-DD HH:MM:SSor RFC3339 --from <= --to
- Constraints:
Instruments
zerodha instruments list [--exchange <EXCHANGE> | --all]- Default (no flags): summary by exchange/type.
- Constraints:
--exchangeand--allare mutually exclusive.
zerodha instruments mf
Orders (single order operations)
zerodha order place --exchange <EX> --symbol <SYM> --txn <BUY|SELL> --type <MARKET|LIMIT|SL|SL-M> --product <CNC|MIS|NRML|MTF> --qty <n> [--price <p>] [--trigger-price <p>] [--validity <DAY|IOC|TTL>] [--validity-ttl <min>] [--variety <v>] [--tag <t>]- Constraints:
- required:
--exchange --symbol --txn --type --product --qty --qty > 0- LIMIT requires
--price > 0 - SL requires both
--price > 0and--trigger-price > 0 - SL-M requires
--trigger-price > 0 - TTL validity requires
--validity-ttl > 0
- required:
- Constraints:
zerodha order modify --order-id <id> [fields...]- Constraints:
--order-idrequired- At least one modifiable field required.
- If provided,
--txnmust be BUY/SELL;--typemust be MARKET/LIMIT/SL/SL-M;--validitymust be DAY/IOC/TTL.
- Constraints:
zerodha order cancel --order-id <id> [--variety <v>] [--parent-order-id <id>]- Constraints:
--order-idrequired.
- Constraints:
zerodha order exit --order-id <id> [--variety <v>] [--parent-order-id <id>]- Constraints:
--order-idrequired.
- Constraints:
Orders (orderbook/trades)
zerodha orders listzerodha orders show --order-id <id>- Constraints:
--order-idrequired.
- Constraints:
zerodha orders trades [--order-id <id>]
Positions
zerodha positionszerodha positions convert --exchange <EX> --symbol <SYM> --old-product <CNC|MIS|NRML|MTF> --new-product <CNC|MIS|NRML|MTF> --position-type <day|overnight> --txn <BUY|SELL> --qty <n>- Constraints:
- all flags above required
--qty > 0
- Constraints:
Holdings
zerodha holdingszerodha holdings auctionszerodha holdings auth-initiate [--type <equity|mf>] [--transfer-type <pre|post|off|gift>] [--exec-date YYYY-MM-DD] [--isin <isin> ...] [--qty <float> ...]- Constraints:
- if
--typeset, must beequity|mf - if
--transfer-typeset, must bepre|post|off|gift - if
--exec-dateset, format must beYYYY-MM-DD --isinand--qtymust have matching counts- each
--qtymust be> 0
- if
- Constraints:
Margins
zerodha margins [--segment <all|equity|commodity>]zerodha margins order --exchange <EX> --symbol <SYM> --txn <BUY|SELL> --type <MARKET|LIMIT|SL|SL-M> --product <CNC|MIS|NRML|MTF> --qty <n> [--price <p>] [--trigger-price <p>] [--variety <v>] [--compact]zerodha margins basket --exchange <EX> --symbol <SYM> --txn <BUY|SELL> --type <MARKET|LIMIT|SL|SL-M> --product <CNC|MIS|NRML|MTF> --qty <n> [--price <p>] [--trigger-price <p>] [--variety <v>] [--compact] [--consider-positions]zerodha margins charges --exchange <EX> --symbol <SYM> --txn <BUY|SELL> --type <MARKET|LIMIT|SL|SL-M> --product <CNC|MIS|NRML|MTF> --qty <n> --avg-price <p> [--price <p>] [--trigger-price <p>] [--variety <v>] [--order-id <id>]- Shared constraints for order/basket/charges:
- required:
--exchange --symbol --txn --type --product --qty --qty > 0- LIMIT requires
--price > 0 - SL requires both
--price > 0and--trigger-price > 0 - SL-M requires
--trigger-price > 0
- required:
- Additional charges constraint:
--avg-price > 0
- Shared constraints for order/basket/charges:
GTT
zerodha gtt place [gtt flags]zerodha gtt modify --trigger-id <id> [gtt flags]zerodha gtt listzerodha gtt show --trigger-id <id>zerodha gtt delete --trigger-id <id>
GTT common flags:
--exchange <EX> --symbol <SYM> --last-price <p> --txn <BUY|SELL> [--product <CNC|MIS|NRML|MTF>] [--type <single|two-leg>]- For
singletype:--trigger <p> --limit-price <p> --qty <q>
- For
two-legtype:--lower-trigger <p> --lower-limit-price <p> --lower-qty <q>--upper-trigger <p> --upper-limit-price <p> --upper-qty <q>
GTT constraints:
--exchange --symbol --txnrequired--last-price > 0--txninBUY|SELL--productinCNC|MIS|NRML|MTF--trigger-id > 0for show/modify/delete
Mutual Funds
MF Orders
zerodha mf orders place --symbol <SYM> --txn <BUY|SELL> [--qty <q>] [--amount <amt>] [--tag <t>]- Constraints:
--symboland--txnrequired- at least one of
--qtyor--amountmust be> 0 --qtyand--amountcannot be negative
- Constraints:
zerodha mf orders list [--from YYYY-MM-DD --to YYYY-MM-DD]- Constraints:
--fromand--tomust be provided together- date format:
YYYY-MM-DD
- Constraints:
zerodha mf orders show --order-id <id>- Constraints:
--order-idrequired
- Constraints:
zerodha mf orders cancel --order-id <id>- Constraints:
--order-idrequired
- Constraints:
MF SIPs
zerodha mf sips place --symbol <SYM> --amount <amt> --instalments <n> --frequency <f> [--instalment-day <1..31>] [--initial-amount <amt>] [--trigger-price <p>] [--step-up <v>] [--sip-type <v>] [--tag <t>]- Constraints:
- required:
--symbol --amount --instalments --frequency --amount > 0,--instalments > 0--instalment-dayif provided must be in1..31(0 means not set)--initial-amountand--trigger-pricecannot be negative
- required:
- Constraints:
zerodha mf sips modify --sip-id <id> [--amount <amt>] [--frequency <f>] [--instalment-day <1..31>] [--instalments <n>] [--step-up <v>] [--status <v>]- Constraints:
--sip-idrequired- at least one modifiable field required
- numeric fields cannot be negative
- Constraints:
zerodha mf sips cancel --sip-id <id>- Constraints:
--sip-idrequired
- Constraints:
zerodha mf sips listzerodha mf sips show --sip-id <id>- Constraints:
--sip-idrequired
- Constraints:
MF Holdings
zerodha mf holdingszerodha mf holdings show --isin <isin>- Constraints:
--isinrequired
- Constraints:
zerodha mf holdings isins
Synonym Map
Use these mappings during intent parsing.
Market data
quotesynonyms:price,live price,current price,quote,snapshotltpsynonyms:ltp,last traded price,last price,tickohlcsynonyms:open high low close,ohlc,candle snapshothistoricalsynonyms:history,candles,chart data,time series
Account and auth
profilesynonyms:account details,user profile,my accountloginsynonyms:authenticate,sign in,connect kiterenewsynonyms:refresh access token,renew tokenlogoutsynonyms:sign out,clear session
Bootstrap
install clisynonyms:install zerodha cli,setup zerodha cli,command not found,zerodha not installed
Orders and tradebook
order placesynonyms:buy,sell,place order,new order,execute tradeorder modifysynonyms:edit order,change order,update orderorder cancelsynonyms:cancel order,delete orderorder exitsynonyms:square off order,exit orderorders listsynonyms:orderbook,all ordersorders tradessynonyms:tradebook,fills,executed trades
Portfolio
positionssynonyms:open positions,net positionspositions convertsynonyms:convert position,change product typeholdingssynonyms:portfolio holdings,stocks held,demat holdingsholdings auctionssynonyms:auction holdings,auction eligible
Risk/margins
marginssynonyms:available margin,used margin,fundsmargins ordersynonyms:margin required,order margin estimatemargins basketsynonyms:basket margin,combined marginmargins chargessynonyms:brokerage estimate,charges,fees
GTT
gttsynonyms:good till trigger,trigger order,price alert ordergtt two-legsynonyms:oco,one cancels other,bracket trigger
Mutual funds
mf orderssynonyms:mutual fund order,fund buy/sellmf sipssynonyms:sip,systematic investment planmf holdingssynonyms:mutual fund portfolio,fund holdings
Routing Procedure
- Detect whether this is an install/bootstrap request, login/auth bootstrap request, or a normal
zerodhacommand request. - For install/bootstrap: pick the OS-specific installer command.
- For login/auth bootstrap: follow "Login Flow (Multi-Message)" and emit only the next runnable command.
- Otherwise detect intent domain using synonyms.
- Pick the narrowest command path.
- Extract required entities/flags.
- Validate against constraints above.
- If fields are missing, ask for only missing required inputs.
- Output one runnable command string.
Intent to Command Defaults
- If user asks generic "install zerodha cli":
- Linux/macOS:
curl -fsSL https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.sh | sh - Windows:
irm https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.ps1 | iex
- Linux/macOS:
- If user asks generic "login" and no auth fields are provided:
- ask for
api_keyandapi_secretfirst (profile defaults todefaultunless specified)
- ask for
- If user provides
api_key+api_secretbut no token/mode:- emit profile setup command first, then ask for token mode (
--request-tokenor--callback)
- emit profile setup command first, then ask for token mode (
- If user asks generic "show my profile": use
zerodha profile show. - If user asks generic "show orders": use
zerodha orders list. - If user asks generic "show trades": use
zerodha orders trades. - If user asks generic "show positions": use
zerodha positions. - If user asks generic "show holdings": use
zerodha holdings. - If user asks generic "show margins": use
zerodha margins --segment all. - If user asks "list instruments" without exchange: use
zerodha instruments list.
Output Contract For Downstream Agents
When responding with a routed command, return:
command: exact runnable command (installer command for bootstrap, otherwisezerodha ...)why: one-line reasonmissing: required fields still missing (empty if none)
如何使用「Zerodha」?
- 打开小龙虾AI(Web 或 iOS App)
- 点击上方「立即使用」按钮,或在对话框中输入任务描述
- 小龙虾AI 会自动匹配并调用「Zerodha」技能完成任务
- 结果即时呈现,支持继续对话优化