AGENT SKILL
use-cli
only-if-asked
- License 许可
- MIT
- 所属仓库
- xmkqv/money-tree
- 最近更新
- 2026-11-09
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- use-cli
- description
- only-if-asked
03 SKILL.md 正文
cli
rules
- idiomatic typed typescript
- skills.guides(spec, code)
- completions install with an explicit shell, not autodetection
- argument types derive from the parser, not a second declaration
- validation lives in the grammar, not the handler
- a destructive command takes a required flag
- environment reads are lazy so completion runs without them
{name}/
main.ts
package.json
tsconfig.json
…
import { object, or } from '@optique/core/constructs'
import { message } from '@optique/core/message'
import { command, constant } from '@optique/core/primitives'
import { run } from '@optique/run'
const cli = or(
command(
'{noun}',
command('{verb}', object({ action: constant('{noun}.{verb}') }), {
brief: message`{Verb} the {noun}.`
}),
{ brief: message`The {noun}.` }
)
)
const argv = Bun.argv.slice(2)
const cmd = run(cli, {
args: argv.length ? argv : ['--help'],
programName: '{name}',
help: 'both',
completion: { command: true }
})
switch (cmd.action) {
case '{noun}.{verb}':
await {verb}{Noun}()
break
}
{noun} {verb}(…) → {return}
{another-noun} {verb}(…) → {return}
…
use-cli(name, install?, shell?)
log clispec{infer(context or AskUserQuestion())}
bun init {name} && cd {name} && bun add @optique/core @optique/run
implement the design
if install, bun link
if shell, {name} completion {shell} > {dir on fpath}/_{name}