Agent skill

Test Generator

by laolaoshiren in laolaoshiren/claude-code-skills-zh

依据真实代码契约生成并验证单元测试或集成测试。用于用户要求为函数、类、接口或缺陷补测试、提高覆盖率、生成回归用例或完善测试策略时;先读取现有测试与调用方,不猜测空值、异常或超时行为,不自动安装框架或访问生产依赖。

MITAuto-check passed

Install Test Generator

skills CLI
$ npx skills add laolaoshiren/claude-code-skills-zh --skill test-generator -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install laolaoshiren/claude-code-skills-zh test-generator --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/test-generator .claude/skills/test-generator && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
test-generator
GitHub stars
879
Token cost
~383 tokens
SKILL.md length
64 words
Files
1
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

依据真实代码契约生成并验证单元测试或集成测试。用于用户要求为函数、类、接口或缺陷补测试、提高覆盖率、生成回归用例或完善测试策略时;先读取现有测试与调用方,不猜测空值、异常或超时行为,不自动安装框架或访问生产依赖。

  • Works in 5 steps: 读取真实契约 → 选择测试层级 → 设计用例 → …
  • SKILL.md covers 工作流程, 安全与授权边界 and 输出
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Test Generator is an agent skill from laolaoshiren/claude-code-skills-zh. 依据真实代码契约生成并验证单元测试或集成测试。用于用户要求为函数、类、接口或缺陷补测试、提高覆盖率、生成回归用例或完善测试策略时;先读取现有测试与调用方,不猜测空值、异常或超时行为,不自动安装框架或访问生产依赖。

Its SKILL.md is about 380 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

The repository describes itself as: 面向中文开发者的 Claude Code Skills / Agents / Plugins 精选与原创技能库|按场景分类|复制即装|持续更新. The licence is MIT.

Example prompts

  • “/test-generator”

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. 读取真实契约
  2. 选择测试层级
  3. 设计用例
  4. 实现最小测试
  5. 运行与复验

What it can do on your machine

Read from SKILL.md and the folder at commit 633f21c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are markdown).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Test Generator loads about 383 tokens when it runs. Until then it costs about 30 tokens; SKILL.md has 64 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~30
When it runs · the whole SKILL.md, loaded when a task matches
~383

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from laolaoshiren/claude-code-skills-zh at commit 633f21c, republished under its MIT licence (© laolaoshiren). 64 words, ~383 tokens.

Download SKILL.mdSave it as .claude/skills/test-generator/SKILL.md (or your agent's skills folder).
name
test-generator
description
依据真实代码契约生成并验证单元测试或集成测试。用于用户要求为函数、类、接口或缺陷补测试、提高覆盖率、生成回归用例或完善测试策略时;先读取现有测试与调用方,不猜测空值、异常或超时行为,不自动安装框架或访问生产依赖。

测试生成器

工作流程

1. 读取真实契约

检查目标代码及其:

  • 类型定义、公开文档、调用方和错误处理路径。
  • 现有测试、fixture、测试配置、依赖清单和项目测试命令。
  • 输入输出、副作用、状态变化、并发语义和系统边界。
  • 适用的仓库规则、Git 状态及本轮允许修改的范围。

区分“代码当前行为”和“产品期望行为”。两者冲突或契约不明确且会改变断言时,先列出证据与待确认假设;不要用测试固化猜测。

2. 选择测试层级
  • 纯逻辑优先使用快速、确定的单元测试。
  • 在系统边界隔离时间、随机数、文件系统、网络或第三方服务,避免 mock 被测模块的内部实现。
  • 需要验证真实组件协作时使用集成测试,可采用临时目录、测试数据库或受控服务,并确保资源隔离和清理。
  • 修复缺陷时先写能复现真实问题的最小回归用例,再验证修复。

只覆盖契约或可达路径中真实存在的正常、边界与失败场景。空值、类型错误、超时和数据库异常不是每个函数的固定要求。

3. 设计用例

每个用例应说明:

  • 对应的契约、缺陷或分支。
  • 输入与环境安排。
  • 可观察结果,而非内部实现细节。
  • 必要的清理和跨用例隔离。

优先参数化重复场景,并沿用仓库现有的测试命名、目录、fixture 和断言风格。不要因项目面向中文用户而强制使用中文函数名。

4. 实现最小测试
  • 只修改目标测试文件和确有必要的 fixture。
  • 不为了让测试通过而随意修改生产代码;若发现产品缺陷,单独报告或按用户要求修复。
  • 不复制未经核实的示例期望值,也不把实现细节写成永久契约。
  • Windows 与 Linux 使用路径 API、系统临时目录和显式编码,不硬编码分隔符、/tmp、换行、大小写、时区或 locale 行为。
5. 运行与复验
  1. 先运行新增或目标测试,确认失败信息与预期一致。
  2. 先检查项目脚本是否会下载依赖、访问外部服务或改变共享状态,再按改动风险运行相关测试;必要时运行完整测试、类型检查或覆盖率命令,潜在外部副作用需先获授权。
  3. 检查 Git diff,确认没有快照、缓存、覆盖率产物或无关文件。
  4. 将基线已有失败与本轮新增失败分开记录。

没有实际运行时,只能说明“已生成、未验证”,不能声称测试通过。

安全与授权边界

  • 未经明确授权,不安装或升级测试框架,不修改 lockfile、全局测试配置、CI 或生产代码。
  • 未经明确授权,不访问真实网络、生产数据库、云服务或含真实凭据的环境。
  • 测试数据不得包含真实个人信息、Token、Cookie、密码或客户数据。
  • 测试必须可重复,不依赖执行顺序,并清理创建的临时资源。
  • 目标文件已有用户修改时,先检查是否重叠,避免覆盖。

输出

markdown
## 测试补充结果

- 目标与契约依据:
- 测试层级与框架:
- 新增或修改文件:

## 用例

| 场景 | 契约依据 | 预期结果 |
|------|----------|----------|

## 验证

- 实际命令与退出状态:
- 相关测试 / 完整测试:
- 基线已有失败:
- 未验证假设与限制:

© laolaoshiren, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/test-generator of laolaoshiren/claude-code-skills-zh.

Open the folder on GitHubat commit 633f21c

Compare with similar skills

Test Generator next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Test Generator compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Test Generator this skilllaolaoshiren/claude-code-skills-zh879—~383Automated safety check: PassMIT
Generatealirezarezvani/claude-skills28k1 repos~1.1kAutomated safety check: PassMIT
Fal Generatenexu-io/open-design100k—~306Automated safety check: PassApache-2.0
Video Generationbytedance/deer-flow84k3 repos~1.4kAutomated safety check: PassMIT
Image Generationonyx-dot-app/onyx32k1 repos~1.7kAutomated safety check: PassCustom licence
Structured Image Generationbytedance/deer-flow84k4 repos~2.9kAutomated safety check: PassMIT

Similar skills

  • Generate

    alirezarezvani/claude-skills

    Generate Playwright tests. An agent skill from alirezarezvani/claude-skills.

    28k GitHub starsUsed in 1 repo~1.1k tokens
    Testing & QAAuto-check passed
  • Fal Generate

    nexu-io/open-design

    Generate images and videos using fal.ai AI models. An agent skill from nexu-io/open-design.

    100k GitHub stars~306 tokensUpdated today
    Media & CreativeAuto-check passed
  • Video Generation

    bytedance/deer-flow

    Generates short videos from a structured JSON prompt, optionally guided by a reference image used as the first or last frame.

    84k GitHub starsUsed in 3 repos~1.4k tokens
    Media & CreativeAuto-check passed
  • Image Generation

    onyx-dot-app/onyx

    Generate or edit raster images (photos, illustrations, textures, sprites, mockups, logos, infographics) using the workspace's configured image-generation provider via onyx-cli image.

    32k GitHub starsUsed in 1 repo~1.7k tokens
    Media & CreativeAuto-check passed
  • Structured Image Generation

    bytedance/deer-flow

    Turns an image request into a structured JSON prompt and runs a bundled Python script to generate the picture, optionally guided by reference images.

    84k GitHub starsUsed in 4 repos~2.9k tokens
    Media & CreativeAuto-check passed
  • Generate Nanobanana

    sickn33/agentic-awesome-skills

    Generate and edit images/video with Google's Gemini media models (Nano Banana 2/Pro, Gemini Omni Flash), with cost-approval gates, reference-image support, and a prompt/output log per call.

    47k GitHub starsUsed in 1 repo~2.8k tokens
    Media & CreativeAuto-check: notes

More from laolaoshiren/claude-code-skills-zh

All 19 skills in this repo
  • API Tester

    laolaoshiren/claude-code-skills-zh

    依据真实 OpenAPI、路由实现和现有测试生成并验证 API 测试。用于用户要求测试接口、补集成测试、验证 API 契约、生成回归用例或排查接口兼容性时;区分“生成测试”和“执行请求”的授权,不猜测状态码、响应结构或 SLA,不在未确认环境中发送写请求。

    879 GitHub stars~614 tokensUpdated 4 days ago
    Auto-check passed
  • Dep Auditor

    laolaoshiren/claude-code-skills-zh

    审计 Node.js、Python、Go、Rust、JVM、Ruby 项目的依赖漏洞、版本健康度与许可证事实;当用户要求检查 package.json、lockfile、requirements、go.mod、Cargo.toml、pom.xml、Gemfile.lock,或生成不改依赖的中文审计报告时使用

    879 GitHub stars~895 tokensUpdated 4 days ago
    Auto-check passed
  • Eslint Fix

    laolaoshiren/claude-code-skills-zh

    安全诊断并修复 ESLint error、warning 和配置兼容问题。用于用户要求运行 lint、解释 ESLint 报错、限定范围自动修复或迁移 ESLint 配置时;优先使用项目锁定的包管理器与版本,先预检再修改,不自动下载最新版或批量改写无关源码。

    879 GitHub stars~436 tokensUpdated 4 days ago
    Auto-check passed
  • Git Workflow

    laolaoshiren/claude-code-skills-zh

    安全处理 Git 状态检查、提交信息、commit、分支、push、PR 和 rebase。用于用户要求检查改动、生成或创建提交、管理分支、推送、发起 PR 或整理历史时;严格区分每个动作的授权,并保护工作树中已有和无关的修改。

    879 GitHub stars~513 tokensUpdated 4 days ago
    Auto-check passed
  • GitHub Actions Gen

    laolaoshiren/claude-code-skills-zh

    分析真实项目并生成或修订安全、可验证的 GitHub Actions workflow;当用户要求创建 CI、测试矩阵、构建、Release、部署、缓存、Secrets、OIDC、PR 自动化或排查 workflow 配置时使用

    879 GitHub stars~1.1k tokensUpdated 4 days ago
    Auto-check: notes
  • Skill Curator

    laolaoshiren/claude-code-skills-zh

    中文 Skill 收录评估器。用于核验 GitHub 上的 Claude Code、Codex、Agent Skills、Plugin、MCP、CLI 或 Agent 工作流是否值得加入精选列表;检查真实资产、安装方式、活跃度、重复项和安全边界,并生成分类、中文描述与可追溯证据。

    879 GitHub stars~756 tokensUpdated 4 days ago
    Auto-check passed

Questions about Test Generator

What does Test Generator do?

依据真实代码契约生成并验证单元测试或集成测试。用于用户要求为函数、类、接口或缺陷补测试、提高覆盖率、生成回归用例或完善测试策略时;先读取现有测试与调用方,不猜测空值、异常或超时行为,不自动安装框架或访问生产依赖。. Test Generator is an agent skill from laolaoshiren/claude-code-skills-zh.

How do I install Test Generator in Claude Code?

Run `npx skills add laolaoshiren/claude-code-skills-zh --skill test-generator -a claude-code`. Or copy the skill folder (skills/test-generator in laolaoshiren/claude-code-skills-zh) into .claude/skills/test-generator in your project. Claude Code loads it when a task matches its description.

How do I install Test Generator in Codex?

Run `npx skills add laolaoshiren/claude-code-skills-zh --skill test-generator -a codex`. Or copy the skill folder (skills/test-generator in laolaoshiren/claude-code-skills-zh) into .agents/skills/test-generator in your project. Codex loads it when a task matches its description.

Can I use Test Generator in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add laolaoshiren/claude-code-skills-zh --skill test-generator -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/test-generator, .gemini/skills/test-generator, .github/skills/test-generator and .opencode/skills/test-generator in your project.

What does Test Generator need to run?

SKILL.md names no scripts, command-line tools or credentials: Test Generator is instructions for the agent only.

Does Test Generator access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Test Generator safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Test Generator use?

Test Generator is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Test Generator use?

About 383 tokens (SKILL.md is roughly 1.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Test Generator?

Skills that share tags, products or a category with Test Generator: Generate (alirezarezvani/claude-skills, 28k stars), Fal Generate (nexu-io/open-design, 100k stars), Video Generation (bytedance/deer-flow, 84k stars) and Image Generation (onyx-dot-app/onyx, 32k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Test Generator?

laolaoshiren (a GitHub user) maintains it in laolaoshiren/claude-code-skills-zh, which has 879 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 5, 2026.

Source: laolaoshiren/claude-code-skills-zh on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.