new-subcommand skillA
new-subcommand is agent-read markdown (skill) from minleev5/devkeel: 为 DevKeel CLI 新增子命令的标准开发流程.
Indexed from public GitHub and served as immutable, content-addressed versions. Install it pinned to an exact SHA-256 with the mdr CLI, and every file is verified against the hash recorded here before it reaches your agent. The deterministic audit below grades the latest version, and the same file always earns the same grade.
What the file says
# 子命令实现
## 何时使用
为 DevKeel CLI 新增一个子命令时(如 `harness <new-cmd>`)。
## 流程
### Step 1: 注册命令
在 `src/index.ts` 中添加:
```typescript
import { runNewCmd } from './commands/new-cmd.js'
program
.command('new-cmd')
.description('中文功能描述')
.option('--flag', '选项说明')
.action((opts) => runNewCmd(opts))
```
### Step 2: 实现命令层
创建 `src/commands/new-cmd.ts`:
```typescript
import * as p from '@clack/prompts'
import { someLogic } from '../lib/new-cmd.js'
export async function runNewCmd(opts?: { flag?: boolean }): Promise<void> {
p.intro('harness new-cmd')
// 交互 + 调用 lib
p.outro('完成')
}
```
命令层只做:读参数 → 交互 → 调用 lib → 输出结果。
### Step 3: 实现逻辑层
创建 `src/lib/new-cmd.ts`:
- 纯函数,不引入 `@clack/prompts`
- 文件操作前 `fs.existsSync` 守卫
- 返回 plain object 或 null,不 throw
### Step 4: 编写测试
创建 `tests/new-cmd.test.ts`:
- 临时目录隔离(`fs.mkdtempSync`)
- 真实文件系统验证
- 覆盖正常路径 + 缺失输入 + 幂等性
### Step 5: 验证
```bash
pnpm lint && pnpm test && pnpm build
node bin/devkeel.js new-cmd --help
```
## Checklist
- [ ] `src/index.ts` 注册命令
- [ ] `src/commands/new-cmd.ts` 交互层
- [ ] `src/lib/new-cmd.ts` 逻辑层(如有复杂逻辑)
- [ ] `tests/new-cmd.test.ts` 测试
- [ ] `pnpm lint` + `pnpm test` 通过Read the whole file at its exact version.
How to install
mdr add minleev5/devkeel/new-subcommand@v1.0.0mdr add minleev5/devkeel/new-subcommand@sha256:83b813cff1129487Pin to a label to follow the author's releases, or to a sha256 to freeze the exact bytes forever. Either way the resolved hash is written to mdr.lock, and mdr install reproduces it on any machine.
[](https://markdownregistry.com/a/art_pyte2pgzblfkabeq)
1 badge views in 30 days
Versions
Audit of the latest version
- pass: Frontmatter block present
- pass: Frontmatter declares a name
- pass: Frontmatter declares a description
- pass: Size between 200 bytes and 200 KB (1730 bytes)
- pass: No zero-width or bidi control characters
- pass: No instruction hidden inside an HTML comment
- pass: No link to an exfiltration or paste host
- pass: No credential-shaped string
- pass: No instruction to send local credentials anywhere
- pass: No text hidden with inline styles
- pass: No prompt-injection phrasing
- pass: No curl or wget piped into a shell
- pass: No recursive delete of root, home or parent
- pass: No instruction to read or print local credentials
- pass: No base64 blob over 200 characters
- pass: No link to a raw IP address
- pass: No script tag
Source
minleev5/devkeel · 3 stars · license MIT · pushed 2026-09-24 · branch master
API
GET https://markdownregistry.com/api/v1/artifacts/art_pyte2pgzblfkabeq GET https://markdownregistry.com/api/v1/resolve?ref=minleev5/devkeel/new-subcommand GET https://markdownregistry.com/api/v1/blob/83b813cff1129487f45b2b7f5e5804ca81130939d47403d9a6186713b8d088ce
Your agent does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.