mcpField
H
hap-cli-environments

hap-cli-environments

github.com/mingdaocomProductivity13143 installsUpdated 5w ago
Repository

About hap-cli-environments

hap-cli-environments is an operating guide for using multiple HAP environments and accounts with the hap CLI. It prioritizes checking the target before each command and asking when the intended environment or account is unclear.

Key features

  1. 01Inspect saved environments and accounts
  2. 02Switch profiles or select one per command
  3. 03Verify targets before destructive actions
  4. 04Avoid reusing tokens across accounts

Use cases

  1. 01Check which HAP account a command will use
  2. 02Run one command in a chosen environment
  3. 03Present options when the target is ambiguous

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mingdaocom/hap-skills --skill hap-cli-environments

After installing, type/hap-cli-environmentsin Claude Code to confirm it loaded.

Details

From the project README

HAP 多环境 / 多账号操作守则

用户可能同时授权了多个 HAP 环境与账号,每个都已登录保存、各有一个名字(见 hap auth accounts)。 “在哪个环境、用哪个账号执行”和命令本身一样重要——选错可能在不该动的环境上造成不可逆后果。

每次操作前

  1. 先看现状:hap --json auth accounts,读出当前在用的是哪个(active),以及每个环境/账号的名字、登录地址、账号、组织。
  2. 把用户的措辞匹配到某个环境/账号:优先按用户说的名字;其次按登录地址/平台(Mingdao SaaS、Nocoly、用户给的私有部署域名)与账号匹配。匹配不唯一就走「停下来问」。
  3. 切换:整段会话用 hap auth use <名字>;只此一条命令用 hap --profile <名字> <命令>。

什么时候必须停下来问

  • 用户没指明用哪个环境/账号,且操作具破坏性(删除应用/工作表/字段/记录、发布、改角色权限、批量写入)。
  • 用户的话能匹配到多个环境/账号、或一个都匹配不上。

此时用问答卡片把候选环境/账号列给用户选,不要擅自挑一个执行,更不要默认用线上/正式的那个。

执行时

  • 每次跑命令前,在回显里点明「当前环境 / 账号 / 组织 / 登录地址」,让用户能一眼核对。
  • 破坏性命令再加一句确认当前不是误选的正式环境。

不该做

  • 不要替用户登录或登出(auth login / auth logout)——除非用户明确要求。
  • 不要把一个账号的 token 跨环境/账号复用——切换一律走 auth use / --profile,不手动搬运 token。

命令速查

hap auth accounts                 # 列出所有环境/账号,当前的带 *
hap --json auth accounts          # 同上,结构化输出供程序判断
hap auth use <名字>               # 切换当前使用的环境/账号
hap --profile <名字> <命令>       # 只让这一条命令临时用某个环境/账号
HAP_PROFILE=<名字> hap <命令>     # 整个终端会话默认用某个环境/账号
hap auth whoami                   # 确认当前用户 / 环境 / 组织

具体命令参数以 hap auth <子命令> --help 为准;要登录/登出或建应用、查数据等本身的操作,回到 hap-cli 及其指向的专门 skill。

Comments

Markdown supported