Token导航 LogoToken导航

Agent Skill · 开发

testing-codegen(测试代码生成器)

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

testing-codegen 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 11,631。

总安装 1,656周安装 67GitHub Stars 24,474下载 520核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:testing-codegen(测试代码生成器)
来源仓库:https://github.com/biomejs/biome
仓库路径:skills/testing-codegen
安装命令:
npx skills add https://github.com/biomejs/biome --skill testing-codegen
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/biomejs/biome --skill testing-codegen

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

用于自动生成符合规范的测试代码片段。适合减少重复劳动并统一测试风格。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。支持断言库选择与 mock 对象创建建议。应结合具体语言特性调整生成逻辑准确性。

testing-codegen 属于开发类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/testing-codegen

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/biomejs/biome --skill testing-codegen;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

testing-codegen 怎么安装?

在终端执行 npx skills add https://github.com/biomejs/biome --skill testing-codegen。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

testing-codegen 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

testing-codegen 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

testing-codegen 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

testing-codegen 用的人多吗?

公开数据是累计安装 1,656 次,近一周安装 67 次,下载 520 次,GitHub 24,474 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

testing-codegen 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 来源仓库有 24,474 星,维护活跃度相对可查。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
testing-codegen

测试代码生成器 · 本页

1,65624,474只读未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Purpose

Use this skill for testing and code generation. Covers snapshot testing with insta and code generation commands.

Prerequisites

  1. Install required tools: just install-tools (installs cargo-insta)
  2. Install pnpm: corepack enable and pnpm install in repo root
  3. Understand which changes require code generation

Common Workflows

Run Tests

# Run all tests
cargo test

# Run tests for specific crate
cd crates/biome_js_analyze
cargo test

# Run specific test
cargo test quick_test

# Show test output (for dbg! macros)
cargo test quick_test -- --show-output

# Run tests with just (uses CI test runner)
just test

# Test specific crate with just
just test-crate biome_cli

Quick Test for Rules

Fast iteration during development:

// In crates/biome_js_analyze/tests/quick_test.rs
// Modify the quick_test function:

const SOURCE: &str = r#"
const x = 1;
var y = 2;
"#;

let rule_filter = RuleFilter::Rule("nursery", "noVar");

Run:

just qt biome_js_analyze

Quick Test for Parser Development

IMPORTANT: Use this instead of building full Biome binary for syntax inspection - it's much faster!

For inspecting AST structure when implementing parsers or working with embedded languages:

// In crates/biome_html_parser/tests/quick_test.rs
// Modify the quick_test function:

#[test]
pub fn quick_test() {
  let code = r#"<button on:click={handleClick}>Click</button>"#;

  let source_type = HtmlFileSource::svelte();
  let options = HtmlParserOptions::from(&source_type);
  let root = parse_html(code, options);
  let syntax = root.syntax();

  dbg!(&syntax, root.diagnostics(), root.has_errors());
}

Run:

just qt biome_html_parser

The dbg! output shows the full AST tree structure, helping you understand:

  • How directives/attributes are parsed (e.g., HtmlAttribute vs SvelteBindDirective)
  • Whether values use HtmlString (quotes) or HtmlTextExpression (curly braces)
  • Token ranges and offsets needed for proper snippet creation
  • Node hierarchy and parent-child relationships

Snapshot Testing with Insta

Run tests and generate snapshots:

cargo test

Review generated/changed snapshots:

# Interactive review (recommended)
cargo insta review

# Accept all changes
cargo insta accept

# Reject all changes
cargo insta reject

# Review for specific test
cargo insta review --test-runner nextest

Snapshot commands:

  • a - accept snapshot
  • r - reject snapshot
  • s - skip snapshot
  • q - quit

Pruning Orphaned Snapshots

When tests are removed or renamed, their old snapshot files become orphaned. Never delete snapshot files manually with rm — always use insta's built-in pruning:

# Delete unreferenced snapshots after a successful test run
cargo insta test --unreferenced delete -p <crate_name>

# Or scoped to specific tests
cargo insta test --unreferenced delete -p biome_cli --test main -- "handle_vue"

This runs the tests first, then deletes any .snap files that no test references. It is the only safe way to clean up snapshots — manual rm risks deleting snapshots that are still needed or creating git conflicts.

Test Lint Rules

# Test specific rule by name
just test-lintrule noVar

# Run from analyzer crate
cd crates/biome_js_analyze
cargo test

Create Test Files

Single file tests - Place in tests/specs/{group}/{rule}/ under the appropriate *_analyze crate for the language:

tests/specs/nursery/noVar/
├── invalid.js           # Code that should generate diagnostics
├── valid.js             # Code that should not generate diagnostics
└── options.json         # Optional: rule configuration

File and folder naming conventions (IMPORTANT):

  • Use valid or invalid in file names or parent folder names to indicate expected behaviour.
  • Files/folders with valid in the name (but not invalid) are expected to produce no diagnostics.
  • Files/folders with invalid in the name are expected to produce diagnostics.
  • When testing cases inside a folder, prefix the name of folder using valid/invalid e.g. validResolutionReact/invalidResolutionReact
tests/specs/nursery/noShadow/
├── invalid.js                     # should generate diagnostics
├── valid.js                       # should not generate diagnostics
├── validResolutionReact/
└───── file.js              # should generate diagnostics
   └── file2.js             # should not generate diagnostics

Multiple test cases - Use .jsonc files with arrays:

// tests/specs/nursery/noVar/invalid.jsonc
[
  "var x = 1;",
  "var y = 2; var z = 3;",
  "for (var i = 0; i < 10; i++) {}"
]

Test-specific options - Create options.json:

{
  "linter": {
    "rules": {
      "nursery": {
        "noVar": {
          "level": "error",
          "options": {
            "someOption": "value"
          }
        }
      }
    }
  }
}

Top-Level Comment Convention (REQUIRED)

Every test spec file must begin with a top-level comment declaring whether it expects diagnostics. The test runner (assert_diagnostics_expectation_comment in biome_test_utils) enforces this and panics if the rules are violated.

Write the marker text using whatever comment syntax the language under test supports. For languages that do not support comments at all, rely on the file/folder naming convention (valid/invalid) instead.

For files whose name contains "valid" (but not "invalid"):

The comment is mandatory — the test panics if it is absent.

For files whose name contains "invalid" (or other names):

The comment is strongly recommended and is also enforced when present: if the comment says should generate diagnostics but no diagnostics appear, the test panics.

Rules enforced by the test runner:

File name containsComment present?Behaviour
"valid" (not "invalid")should not generate diagnosticsPasses if no diagnostics
"valid" (not "invalid")should generate diagnosticsPasses if diagnostics present
"valid" (not "invalid")absentPANIC — comment is mandatory
"invalid" or neutral nameshould not generate diagnosticsPasses if no diagnostics
"invalid" or neutral nameshould generate diagnosticsPasses if diagnostics present
"invalid" or neutral nameabsentNo enforcement (but add it anyway)

Important details:

  • The comment is found by scanning the entire file's leading trivia — it does not have to be literally the first token, but putting it at the very top (line 1) is the established convention.
  • Fixture/support files (e.g. foo.js, bar.ts) that don't contain "valid" or "invalid" in their name do not require a comment, since they are not considered "valid test files" by the runner.
  • Files excluded from comment enforcement regardless of name: .snap, .json, .jsonc.

HTML-ish files (.vue, .svelte, .astro, .html):

These files are analyzed via the workspace-based test path (analyze_with_workspace in biome_test_utils), which checks the expectation comment by scanning the raw file content (not the parsed AST trivia). Use an HTML comment at the very top of the file:

<!-- should not generate diagnostics -->
<script setup lang="ts">
const x = 1;
</script>
<template>{{ x }}</template>
<!-- should generate diagnostics -->
<script>
debugger;
</script>

The same rules apply: valid files must have the comment, invalid files should have it. Do not place the comment inside <script> — put it at the top level of the file as an HTML comment.

Code Generation Commands

After modifying analyzers/lint rules (during development):

just gen-rules          # Updates rule registrations in *_analyze crates
just gen-configuration  # Updates configuration schemas

These lightweight commands generate enough code to compile and test without errors.

Full analyzer codegen (optional — CI autofix handles this):

just gen-analyzer

This is a composite command that runs gen-rules, gen-configuration, gen-migrate, gen-bindings, lint-rules, and format. You typically don't need to run this locally — the CI autofix job does it automatically when you open a PR.

After modifying grammar (.ungram files):

# Specific language
just gen-grammar html

# Multiple languages
just gen-grammar html css

# All languages
just gen-grammar

After modifying formatters:

just gen-formatter html

After modifying configuration:

just gen-bindings

Generates TypeScript types and JSON schema.

Full codegen (rarely needed):

just gen-all

Before committing:

just ready

Runs full codegen + format + lint (takes time).

Or run individually:

just f  # Format Rust and TOML
just l  # Lint code

Run Doctests

Test code examples in documentation comments:

just test-doc

Debugging Tests

Use dbg!() macro in Rust code:

fn some_function() -> &'static str {
  let some_variable = "debug_value";
  dbg!(&some_variable);  // Prints during test
  some_variable
}

Run with output:

cargo test test_name -- --show-output

Tips

  • Snapshot organization: Group by feature/rule in separate directories
  • Test both valid and invalid: Create both valid.js and invalid.js files
  • Options per folder: options.json applies to all tests in that folder
  • .jsonc arrays: Use for multiple quick test cases in script context (no imports/exports)
  • Code generation order: Grammar → Analyzer → Formatter → Bindings
  • CI compatibility: Use just commands when possible (matches CI)
  • Snapshot review: Always review snapshots carefully - don't blindly accept
  • Test performance: Use #[ignore] for slow tests, run with cargo test -- --ignored
  • Parser inspection: Use just qt <package> to run quick_test and inspect AST, NOT full Biome builds (much faster)

For general Biome development tips (string extraction, borrow checker patterns, legacy syntax), see the biome-developer skill.

Common Test Patterns

// Snapshot test in rule file
#[test]
fn test_rule() {
  assert_lint_rule! {
        noVar,
        invalid => [
            "var x = 1;",
            "var y = 2;",
        ],
        valid => [
            "const x = 1;",
            "let y = 2;",
        ]
    }
}

// Quick test pattern
#[test]
#[ignore]  // Uncomment when using
fn quick_test() {
  const SOURCE: &str = r#"
        var x = 1;
    "#;

  let rule_filter = RuleFilter::Rule("nursery", "noVar");
  // Test runs with this configuration
}

Code Generation Dependencies

When you modify...Run during dev...Full (optional, CI does this)
.ungram grammar filesjust gen-grammar <lang>—
Lint rules in *_analyzejust gen-rules && just gen-configurationjust gen-analyzer
Formatter in *_formatterjust gen-formatter <lang>—
Configuration typesjust gen-bindings—
Before committingjust f && just l—
Full rebuild—just gen-all (slow)

References

  • Main testing guide: CONTRIBUTING.md § Testing
  • Insta documentation: https://insta.rs
  • Analyzer testing: crates/biome_analyze/CONTRIBUTING.md § Testing
  • Changeset guide: ../changeset/SKILL.md

平台分布

Codex

34.07%
按下载量换算177

Claude

31.58%
按下载量换算164

Cursor

20.74%
按下载量换算108

Gemini CLI

10.19%
按下载量换算53

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills