dx-audit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DX Audit

DX Audit

Audit or improve what developers import, run, configure, or read when something fails.
  • IS: a bounded review of public APIs, developer-facing errors, CLI commands, exported types, install and first-run behavior, and config, with fixes only when asked.
  • IS NOT: a repo-wide quality sweep (
    pr-reviewer
    ), end-user UI (
    ui-design
    Audit mode), agent trust review (
    ax-audit
    ), docs prose (
    docs-writing
    ), README (
    readme-creator
    ), repository architecture (
    codebase-architecture
    ), or building a new CLI (
    scaffold-cli
    ).
审计或优化开发者在遇到问题时导入、运行、配置或查阅的内容。
  • 适用场景:针对公共API、面向开发者的错误信息、CLI命令、导出类型、安装与首次运行行为及配置的限定性评审,仅在明确要求时提供修复方案。
  • 不适用场景:全仓库质量扫描(
    pr-reviewer
    )、终端用户UI审计(
    ui-design
    Audit模式)、Agent信任评审(
    ax-audit
    )、文档文案撰写(
    docs-writing
    )、README创建(
    readme-creator
    )、仓库架构设计(
    codebase-architecture
    )或构建新CLI(
    scaffold-cli
    )。

Modes

模式

Pick the narrowest mode the request supports, and write a one-line scope receipt before reading code:
ModeWhenOutput
Targeted (default)a named or changed public surfacefindings report, read-only
Fixthe user says fix, improve, simplify, or implementlocalized edits inside the receipt, then verification
Exhaustivethe user explicitly asks for the whole package or every public surfaceevery material finding, partitioned by surface
text
Scope: <mode>; surfaces: <commands/exports/config>; prefixes: <err-, cli->; excludes: <UI, docs, architecture, private internals>
"DX", "gold standard", and "review holistically" do not by themselves widen a targeted audit into exhaustive. When several skills are invoked together, this one owns only the surfaces above.
选择请求支持的最窄模式,并在查看代码前撰写一行范围确认:
模式适用场景输出
定向模式(默认)指定或变更的公共接口只读的问题报告
修复模式用户明确要求修复、优化、简化或实现范围确认内的本地化修改,随后进行验证
全面模式用户明确要求审计整个包或所有公共接口按接口分类的所有实质性问题
text
Scope: <mode>; surfaces: <commands/exports/config>; prefixes: <err-, cli->; excludes: <UI, docs, architecture, private internals>
仅“DX”“黄金标准”或“全面评审”本身不足以将定向审计扩展为全面审计。当多个技能同时调用时,本技能仅负责上述接口范围。

Audit progress

审计流程

text
DX audit progress:
- [ ] 1. Lock the public surface and write the scope receipt
- [ ] 2. Gather local evidence and run the safe probes
- [ ] 3. Select prefixes, then open candidate rules
- [ ] 4. Rank root causes
- [ ] 5. Report, or fix when asked
- [ ] 6. Verify on the same scope
text
DX audit progress:
- [ ] 1. 锁定公共接口并撰写范围确认
- [ ] 2. 收集本地证据并运行安全探测
- [ ] 3. 选择规则前缀,然后查看候选规则
- [ ] 4. 对根本原因排序
- [ ] 5. 生成报告,或按要求修复
- [ ] 6. 在同一范围内验证

1. Lock the public surface

1. 锁定公共接口

Start from
git diff
against the normal base and keep only changed files reachable from a public entry point:
package.json
exports
or
bin
, a command registry, an exported type, a documented config loader, or an observed error path. With no useful diff, use the command, export, error, or config the user named. A private helper enters scope only through a public caller.
从与基准版本的
git diff
开始,仅保留可从公共入口点访问的变更文件:
package.json
的
exports
或
bin
字段、命令注册表、导出类型、文档化的配置加载器或已观察到的错误路径。若无有效diff,则使用用户指定的命令、导出项、错误或配置。私有辅助函数仅在被公共调用者引用时才纳入范围。

2. Gather evidence, then stop

2. 收集证据后停止

  1. Local instructions, the manifest, and the diff or named entry point.
  2. Direct public dependencies and the nearest tests that pin behavior.
  3. Safe probes against the local build:
    • CLI:
      --help
      ,
      --version
      , one success path, one invalid-input path, and the same command with stdout piped (
      | cat
      ) to see non-TTY behavior. Never trigger a real mutation to test DX; use
      --dry-run
      where it exists.
    • Package:
      npx publint
      and
      npx @arethetypeswrong/cli --pack .
      after a build. These inspect packaging, but packing may invoke lifecycle scripts. Inspect those scripts first or use a disposable checkout before calling
      --pack
      .
  4. The prior release contract, only when the diff changes a public export, signature, or return shape.
Stop when the behavior is proven, disproven, private, or out of scope. External research is for an explicit comparison request or a named uncertainty local evidence cannot resolve;
references/standards-map.md
carries the standards this skill already leans on.
  1. 本地说明、清单文件,以及diff或指定的入口点。
  2. 直接公共依赖项和最接近的固定行为测试用例。
  3. 针对本地构建的安全探测:
    • CLI:执行
      --help
      、
      --version
      、一条成功路径、一条无效输入路径,以及通过管道输出的相同命令(
      | cat
      )以查看非TTY行为。测试DX时切勿触发真实的变更操作;若存在
      --dry-run
      则使用该参数。
    • 包:构建后执行
      npx publint
      和
      npx @arethetypeswrong/cli --pack .
      。这些工具会检查打包情况,但打包可能会触发生命周期脚本。请先检查这些脚本,或在调用
      --pack
      前使用一次性检出环境。
  4. 仅当diff变更了公共导出项、签名或返回结构时,才参考先前版本的契约。
当行为被证实、证伪、属于私有内容或超出范围时停止。仅在明确要求对比或本地证据无法解决特定不确定性时才进行外部研究;
references/standards-map.md
包含本技能遵循的标准。

3. Dispatch rules candidate-first

3. 按候选优先级分配规则

Read
rules/_sections.md
, then select prefixes by surface:
PriorityPrefixCategoryDefault impactRules
1
api-
Public API and SDKCRITICAL7
2
err-
Developer-facing errorsCRITICAL5
3
cli-
CLI UX for humans and agentsHIGH13
4
types-
Exported type ergonomicsHIGH5
5
onboard-
Install and first runHIGH5
6
config-
Config ergonomicsMEDIUM3
SurfacePrefixes
Public API entry point
api-
,
types-
, reached
err-
paths
CLI command
cli-
, reached
err-
paths
Exported declarations
types-
, plus
api-
when behavior changed
Install,
package.json
, first run
onboard-
Config loader
config-
, reached
err-
paths
Applicability outranks priority: a CLI-only audit never loads
api-
because API rules rank higher.
Targeted mode: list the filenames for the selected prefixes (the names are the checklist), look for concrete evidence, then open only the rule files a finding needs. Exhaustive mode: read every rule in the selected prefixes.
Capability gates, applied inside a selected prefix:
  • Structured JSON input, schema introspection, and compact polling snapshots apply when automation or agent use is promised, requested, or already supported.
  • Dry-run and confirmation apply to destructive, expensive, or hard-to-reverse mutations.
  • Progress and resume apply to operations that can block, outlive one command, or be retried after ambiguous output.
  • stdin
    applies when the command semantically accepts file or stream data.
  • Stable-contract comparison applies only when a public contract changed.
阅读
rules/_sections.md
,然后按接口选择规则前缀:
优先级前缀分类默认影响级别规则数量
1
api-
公共API与SDKCRITICAL7
2
err-
面向开发者的错误处理CRITICAL5
3
cli-
面向人类与Agent的CLI UXHIGH13
4
types-
导出类型的易用性HIGH5
5
onboard-
安装与首次运行HIGH5
6
config-
配置易用性MEDIUM3
接口前缀
公共API入口点
api-
、
types-
、关联的
err-
路径
CLI命令
cli-
、关联的
err-
路径
导出声明
types-
,若行为变更则加上
api-
安装、
package.json
、首次运行
onboard-
配置加载器
config-
、关联的
err-
路径
适用性优先于优先级:仅审计CLI时绝不会加载
api-
规则,即使API规则优先级更高。
定向模式:列出所选前缀对应的文件名(作为检查清单),寻找具体证据,然后仅打开发现问题所需的规则文件。全面模式:阅读所选前缀下的所有规则。
能力限制,适用于所选前缀内:
  • 当承诺、请求或已支持自动化或Agent使用时,适用结构化JSON输入、模式自省和紧凑轮询快照。
  • 针对破坏性、高成本或难以撤销的变更,适用Dry-run和确认机制。
  • 针对可能阻塞、超出单命令生命周期或可在输出模糊后重试的操作,适用进度跟踪与恢复机制。
  • 当命令在语义上接受文件或流数据时,适用
    stdin
    。
  • 仅当公共契约变更时,适用稳定契约对比。

4. Rank root causes, not instances

4. 对根本原因排序,而非实例

  • Order CRITICAL, HIGH, MEDIUM by each cited rule's frontmatter
    impact
    , copied exactly. Impact is the rule's declared consequence, not a confidence score.
  • Merge repeated instances of one root cause into one finding with up to three representative locations. Missing JSDoc, error codes, or
    --json
    across a surface is one finding, not one per symbol.
  • A missing feature with no current consumer path is not a defect.
  • Targeted mode: every CRITICAL finding, then the highest-value remainder up to five total; summarize the rest by category.
  • 按照每条引用规则前置元数据中的
    impact
    值,依次排列CRITICAL、HIGH、MEDIUM级别。影响级别是规则声明的后果,而非置信度评分。
  • 将同一根本原因的重复实例合并为一项发现,最多包含三个代表性位置。某一接口中缺失JSDoc、错误代码或
    --json
    属于一项发现,而非每个符号对应一项。
  • 当前无消费者路径的缺失功能不视为缺陷。
  • 定向模式:列出所有CRITICAL发现,然后最多列出5个最高价值的剩余发现;其余按类别汇总。

5. Report or fix

5. 生成报告或修复

Audit requests are read-only. A fix request authorizes localized changes inside the receipt, not a redesign of adjacent docs, UI, or architecture.
markdown
undefined
审计请求默认可读模式。修复请求授权在范围确认内进行本地化修改,而非重新设计相邻的文档、UI或架构。
markdown
undefined

DX Audit

DX Audit

Scope:
tool status
CLI;
err-
,
cli-
; 4 files inspected.
Scope:
tool status
CLI;
err-
,
cli-
; 4 files inspected.

Findings

Findings

  • [HIGH]
    cli-idempotent-resume
    at
    src/start.ts:42
    : retrying the same target creates a second job. Fix: return the existing job id and state unless the caller passes
    --fresh
    .
  • [HIGH]
    cli-idempotent-resume
    at
    src/start.ts:42
    : retrying the same target creates a second job. Fix: return the existing job id and state unless the caller passes
    --fresh
    .

Deferred

Deferred

  • 2 lower-impact config candidates were outside the locked CLI scope.

List only files with findings; a clean surface gets one pass line naming the surfaces and rule files checked. In fix mode, replace `Deferred` with `Changed` and `Verification` (the exact commands or probes that passed). Length follows findings, not the template.
  • 2 lower-impact config candidates were outside the locked CLI scope.

仅列出存在问题的文件;无问题的接口只需一行说明检查的接口和规则文件。修复模式下,将`Deferred`替换为`Changed`和`Verification`(即通过的具体命令或探测)。长度由发现的问题决定,而非模板。

6. Verify on the same scope

6. 在同一范围内验证

Re-open every touched or cited location, rerun the same probes and focused project checks, and reapply the same candidate rules. Match the evidence to the claim: a clean build does not prove CLI behavior, a runtime probe does not prove exported types, and only
attw
or a consumer-style
tsc
import proves a types resolution.
重新检查所有修改或引用的位置,重新运行相同的探测和聚焦项目检查,并重新应用相同的候选规则。确保证据与声明匹配:干净的构建不能证明CLI行为,运行时探测不能证明导出类型,只有
attw
或消费者风格的
tsc
导入才能证明类型解析正确。

Reference files

参考文件

FileRead when
rules/_sections.md
Every audit, for prefix applicability and priority
rules/<prefix>-*.md
A candidate has evidence, or exhaustive mode
references/standards-map.md
A finding needs an external citation, the user asks why something is a rule, or a borderline call needs a tie-break
references/evaluation-scenarios.md
Changing this skill; never during a user task
rules/_template.md
Adding or editing a rule
文件阅读场景
rules/_sections.md
每次审计,用于确定前缀的适用性和优先级
rules/<prefix>-*.md
候选规则有证据支持,或处于全面模式
references/standards-map.md
发现需要外部引用、用户询问规则原因,或边界情况需要决策依据
references/evaluation-scenarios.md
修改本技能时;用户任务期间绝不加载
rules/_template.md
添加或编辑规则时

Gotchas

注意事项

  • npx <pkg>
    and a global install probe the registry copy, not the working tree.
    --help
    , exit codes, and error strings then describe a released version. Build, then invoke the local entry point (
    node ./dist/cli.js
    ).
  • process.stdout.isTTY
    is
    undefined
    under a pipe, not
    false
    .
    A guard written as
    isTTY === false
    never disables color or spinners when piped, so ANSI codes reach the redirected file. Probe with
    | cat
    rather than trusting the guard.
  • process.exit(1)
    right after
    console.log
    can truncate the output it was meant to explain.
    stdout writes are asynchronous when piped, so a CLI that prints usage and calls
    exit()
    can emit nothing under
    | cat
    . The fix is
    process.exitCode = 1
    and a natural return (
    cli-exit-codes
    ).
  • An
    exports
    map that reads correctly can still resolve wrong.
    "require"
    pointing at a
    .js
    file under
    "type": "module"
    masquerades as CJS, and a
    types
    condition listed after
    import
    is never reached.
    publint
    and
    attw
    catch both; reading the map does not (
    onboard-exports-resolve-typed
    ).
  • A rule id cited from memory drifts from the file. The frontmatter title and impact are the contract. Open the file before citing it, and drop the citation if no such file exists.
  • Downgrading an impact because the instance feels small hides a class of defect. Exit 0 on failure in one subcommand is still HIGH; the CI gate it defeats is the same. Copy the frontmatter value.
  • npx <pkg>
    和全局安装探测的是注册表中的副本,而非工作目录版本。
    --help
    、退出码和错误字符串描述的是已发布版本。请先构建,然后调用本地入口点(
    node ./dist/cli.js
    )。
  • 管道环境下
    process.stdout.isTTY
    为
    undefined
    ,而非
    false
    。
    若守卫逻辑写为
    isTTY === false
    ,则在管道输出时绝不会禁用颜色或加载动画,导致ANSI代码进入重定向文件。请使用
    | cat
    进行探测,而非依赖守卫逻辑。
  • 在
    console.log
    后立即调用
    process.exit(1)
    可能会截断本应说明问题的输出。
    管道环境下stdout写入是异步的,因此打印用法后调用
    exit()
    的CLI在
    | cat
    下可能无输出。修复方案是设置
    process.exitCode = 1
    并自然返回(
    cli-exit-codes
    规则)。
  • 读取正确的
    exports
    映射仍可能解析错误。
    在
    "type": "module"
    下,
    "require"
    指向
    .js
    文件会伪装成CJS,而
    types
    条件列在
    import
    之后则永远不会被读取。
    publint
    和
    attw
    能发现这两种情况;仅读取映射无法发现(
    onboard-exports-resolve-typed
    规则)。
  • 凭记忆引用的规则ID可能与文件中的不符。 前置元数据中的标题和影响级别是契约。引用前请打开文件,若不存在该文件则删除引用。
  • 因实例看似轻微而降低影响级别会掩盖一类缺陷。 某个子命令执行失败却返回0仍属于HIGH级别;它绕过的CI检查是相同的。请直接复制前置元数据中的值。

Related skills

相关技能

  • ui-design
    Audit mode: rendered end-user frontend quality and accessibility
  • ax-audit
    : same files, different reader; asks whether an agent can operate and recover, where this skill asks whether a developer finds the surface ergonomic
  • scaffold-cli
    : builds a new CLI with these patterns already in place; this skill audits what exists
  • pr-reviewer
    : general correctness and structure of a diff
  • docs-writing
    : documentation prose and information quality
  • readme-creator
    : README structure and first-reader narrative
  • agents-md
    : AGENTS.md and CLAUDE.md instruction files
  • codebase-architecture
    : repository structure and module contracts inside the repo, rather than the surface a package ships outward
Maintenance only:
evals/evals.json
contains regression scenarios for changes to this skill; it does not load during a user task.
  • ui-design
    Audit模式:渲染后的终端用户前端质量与可访问性
  • ax-audit
    :检查同一文件,但关注点不同;本技能关注开发者对接口的易用性感受,而
    ax-audit
    关注Agent能否操作与恢复
  • scaffold-cli
    :构建已包含这些模式的新CLI;本技能审计现有内容
  • pr-reviewer
    :diff的通用正确性与结构
  • docs-writing
    :文档文案与信息质量
  • readme-creator
    :README结构与首次阅读叙事
  • agents-md
    :AGENTS.md和CLAUDE.md说明文件
  • codebase-architecture
    :仓库内部的结构与模块契约,而非包对外提供的接口
仅维护用途:
evals/evals.json
包含本技能变更的回归场景;用户任务期间不会加载。",