Token导航 LogoToken导航

Agent Skill · 研究检索

smart-code-test-unit(智能代码测试单元)

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

smart-code-test-unit 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为调用外部服务;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 71,089。

总安装 196周安装 8GitHub Stars 公开资料未说明下载 63核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/lordprotein/smart-code-test-unit --skill smart-code-test-unit

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

smart-code-test-unit 用于辅助测试设计、自动化测试和回归验证,帮助编写单元测试或端到端测试。适用于根据失败日志定位问题、生成测试计划或整理用例的场景。使用时需确认项目测试框架、运行命令和夹具数据配置。涉及浏览器或外部服务时,应区分本地模拟与生产环境,避免误改真实逻辑。

不能仅依赖工具输出作为最终结论,需人工复核测试有效性。

来源仓库内路径:skills/smart-code-test-unit

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/lordprotein/smart-code-test-unit --skill smart…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

smart-code-test-unit 怎么安装?

在终端执行 npx skills add https://github.com/lordprotein/smart-code-test-unit --skill smart-code-test…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

smart-code-test-unit 支持哪些 AI 工具?

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

smart-code-test-unit 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

smart-code-test-unit 是免费的吗?

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

smart-code-test-unit 用的人多吗?

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

smart-code-test-unit 安全吗?

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

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

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

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

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

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

研究检索类 Skill 对比

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

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
smart-code-test-unit

智能代码测试单元 · 本页

196—调用外部服务未明确通过

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

SKILL.md 原文

Unit Test Expert

Overview

Generate high-quality unit tests or review existing tests using industry best practices. Works in two modes:

  • Mode 1: Generate Tests — analyze code and produce comprehensive tests
  • Mode 2: Review Tests — evaluate existing tests for quality, coverage, and antipatterns

Default to Generate mode unless the user explicitly asks to review existing tests or the input is clearly test code.

Scope

This skill is focused exclusively on unit testing:

  • Tests one unit in isolation (function, class, component)
  • Dependencies are mocked, stubbed, or faked
  • No E2E tests, no full integration tests spanning multiple real services
  • "Integration" within unit scope is acceptable: e.g., testing a component with its simple presentational children, or a service with an in-memory repository

Severity Levels

LevelNameDescriptionAction
P0CriticalFalse confidence — test passes but doesn't verify correctnessMust fix immediately
P1HighMajor quality issue — fragile, over-mocked, missing critical coverageShould fix before merge
P2MediumMaintainability concern — readability, naming, structureFix in this PR or follow-up
P3LowStyle or minor suggestionOptional improvement

Mode 1: Generate Tests

0) Determine test scope

MANDATORY — you MUST perform this step BEFORE preflight. Do NOT skip it.

  • Analyze the target code and determine which categories are present:

- Business logic / domain model — core rules, algorithms, calculations, state machines - UI components — components that render UI, handle user interactions, manage visual state - Utilities / helpers / hooks — pure functions, transformers, validators, formatters, parsers, hooks/composables

  • Ask the user (multiselect) which types of tests to generate:

- Unit tests for business logic - Unit tests for UI components - Unit tests for utilities / hooks

  • If the code clearly belongs to only one category, still confirm with the user before proceeding.
  • Generate only the selected categories — do NOT generate tests for unselected categories.

1) Preflight context

  • Use git status -sb, git diff --stat, and git diff to scope changes. If user specifies files, analyze those instead.
  • Identify the programming language, test framework, and assertion library used in the project.
  • Search for existing tests (rg -g "*test*" -g "*spec*" --files) to discover:

- Test directory structure and file naming conventions - Test framework and assertion patterns in use - Helper functions, builders, fixtures, or factories already defined - Naming conventions for test methods

  • If no existing tests found, ask user about preferred framework or propose a standard one for the language.

Edge cases:

  • No changes: If git diff is empty, ask user which files/modules to generate tests for.
  • Large diff (>500 lines): Summarize modules first, then ask user to prioritize which to test.
  • Test files in diff: Switch to Mode 2 (Review) for the test files, Mode 1 for production files.

2) Classify code (Khorikov matrix)

MANDATORY — you MUST load and apply the classification matrix. Do NOT skip this step, do NOT generate tests without classifying first.

  • Load references/testing-principles.md for the classification matrix.
  • Categorize each unit of code:
CategoryTest strategy
Domain model / algorithmsUnit test extensively — highest priority
UI componentTest rendering, interactions, states, a11y (if selected in step 0)
Utility / pure function / hookOutput-based testing, parameterized tests (if selected in step 0)
Trivial code (getters, DTOs, one-line delegations)Skip — no tests needed
Controllers / orchestratorsIntegration tests only — don't unit test
Overcomplicated code (high complexity + many dependencies)Recommend refactoring first, then test
  • Report the classification to the user before generating tests.
  • If code is overcomplicated, suggest applying Humble Object pattern to extract testable logic.

3) Determine test scenarios

MANDATORY — you MUST load scenario identification techniques before determining scenarios. Do NOT rely on general knowledge alone.

  • Load references/business-logic-testing.md for scenario identification techniques.
  • For each domain logic unit, identify:

- Happy paths: Core business rules, primary use cases - Decision table scenarios: All condition combinations for complex rules - Boundary conditions: Min, max, zero, empty, null, off-by-one - Error paths: Invalid input, constraint violations, exception handling - Invariants: Conditions that must always hold after any operation - State transitions: Valid and invalid transitions (if applicable)

  • Prioritize: business-critical paths first, edge cases second, defensive checks last.

4) Generate tests

MANDATORY — you MUST load the reference files listed below before generating any test code.

  • Load references/test-design-patterns.md for patterns.
  • Load references/test-doubles-guide.md for double selection.
  • If UI component tests selected → also load references/ui-component-testing.md for UI-specific principles, query priority, snapshot rules, and UI antipatterns.
  • If utility / hooks tests selected → also load references/utility-and-hooks-testing.md for parameterized testing, boundary analysis, hooks testing strategies, and utility antipatterns.
  • Apply these rules:

Structure:

  • Follow AAA pattern (Arrange-Act-Assert) with clear visual separation
  • One Act per test — never test multiple behaviors in one test
  • No conditional logic in tests (no if/for/try-catch)
  • Group tests logically (by behavior/feature, using describe/context if framework supports)

Naming:

  • Use project's existing naming convention if detected
  • Otherwise use descriptive names: test_[scenario]_[expected_result] or test_[behavior_description]
  • Name must describe WHAT is tested and WHAT the expected outcome is
  • Use domain language, not implementation terms

Test doubles:

  • Default to real objects for in-process dependencies
  • Use stubs only when real setup is impractical and behavior is irrelevant to this test
  • Mock ONLY unmanaged out-of-process dependencies (external APIs, SMTP, payment gateways)
  • Create adapters/wrappers for third-party libraries — never mock what you don't own
  • Prefer fakes over mocks when dependency has complex behavior

Data setup:

  • Use builders/factories if they exist in the project
  • Create new builders if the same object setup repeats 3+ times
  • Use parameterized tests for decision tables and boundary value sets
  • Every magic value in a test should have a clear purpose (via variable name or context)

Typing (TypeScript / typed languages):

  • Always use real types from the project — import and reuse existing interfaces, types, enums
  • If the real type is not found — use unknown, never any
  • any is forbidden unless there is absolutely no other option

Assertions:

  • Assert on specific expected values, not just is not None or doesn't throw
  • For error paths, assert on system state AFTER the error (not just the exception)
  • One logical concept per test (may be multiple assert statements)
  • Use the project's assertion style (expect/assert/should)

5) Self-check against antipatterns

MANDATORY — you MUST load the antipatterns checklist and run EVERY check below for EACH generated test. Do NOT output tests without completing this verification.

  • Load references/antipatterns-checklist.md.
  • Before outputting, verify each generated test against:

- Not a Liar — has meaningful assertions - Not a Giant — single Act, focused assertions - Not a Mockery — minimal, justified mocks - Not an Inspector — tests public behavior only - Not Fragile — would survive refactoring - No shared mutable state - No conditional logic - Not testing trivial code

  • If any check fails, fix the test before outputting.

6) Output format

## Test Generation Summary

**Source**: X files analyzed, Y functions/methods identified
**Classification**: Domain logic: A, UI components: B, Utilities/hooks: C, Trivial (skipped): D, Controllers (skip for unit test): E
**Tests generated**: Z test cases

---

## Code Classification

> **Required.** Classify every analyzed function/method before generating tests.

| File / Function | Category | Test strategy |
|----------------|----------|---------------|
| (list each unit) | Domain model / UI / Utility / Trivial / Controller / Overcomplicated | Unit test / UI test / Output-based / Skip / Integration / Refactor first |

---

## Generated Tests

### [filename_test.ext]

[Test code with comments explaining the scenario for non-obvious cases]

---

## Coverage Notes

- **Tested**: business rules, UI components, utilities/hooks covered
- **Not tested (trivial)**: skipped trivial code
- **Out of scope**: controllers (integration), overcomplicated (refactor first)

---

## Next Steps

1. **Run tests** — Shall I run the generated tests to verify they pass?
2. **Add more scenarios** — Any edge cases or business rules I missed?
3. **Create test helpers** — Shall I extract builders/factories for reusable setup?

Important: Do NOT write test files to disk until user explicitly confirms. Present the generated tests in the output first, then ask how to proceed.


Mode 2: Review Tests

1) Preflight context

  • Collect existing test files: from git diff or user-specified files.
  • Identify test framework, assertion library, and project conventions.
  • Read the corresponding production code to understand what's being tested.

Edge cases:

  • No test files found: Inform user and offer to switch to Mode 1 (Generate).
  • Mixed test and production code in diff: Review tests (Mode 2), generate tests for uncovered production code (Mode 1).

2) Evaluate against checklist

MANDATORY — you MUST load ALL THREE reference files below. Do NOT evaluate from memory alone.

  • Load references/test-review-checklist.md for the full checklist.
  • Load references/antipatterns-checklist.md for antipattern detection.
  • Load references/test-doubles-guide.md for doubles assessment.

MANDATORY procedure — follow this exact sequence for every review. Do NOT skip steps or merge findings:

  1. Scan for Liars (P0) — meaningful assertions in every test?
  2. Check isolation (P0) — shared mutable state?
  3. Check doubles usage (P1) — over-mocking? mocking internals?
  4. Check fragility (P1) — behavior or implementation verification?
  5. Check coverage quality (P1) — critical paths tested?
  6. Check readability (P2) — names, AAA structure, clarity
  7. Check speed (P2) — unnecessary delays or real I/O?
  8. Check for trivial tests (P3) — testing getters/constructors?

3) Assess severity

Assign severity to each finding using the severity levels defined above (P0-P3).

4) Output format

## Test Review Summary

**Files reviewed**: X test files, Y test cases
**Overall assessment**: [APPROVE / REQUEST_CHANGES / COMMENT]
**Coverage quality**: [Good / Adequate / Insufficient]

---

## Findings

### P0 - Critical
(none or list)

### P1 - High
1. **[test_file:line]** Brief title
   - **Antipattern**: Which antipattern
   - **Problem**: What's wrong
   - **Impact**: Why it matters
   - **Fix**: Suggested correction with code example

### P2 - Medium
2. (continue numbering)

### P3 - Low
...

---

## Coverage Gaps

- [Business rules / paths not covered by any test]

## Positive Observations

- [What's done well — reinforce good practices]

---

## Next Steps

I found X issues (P0: _, P1: _, P2: _, P3: _).

**How would you like to proceed?**

1. **Fix all** — I'll implement all suggested fixes
2. **Fix P0/P1 only** — Address critical and high priority issues
3. **Fix specific items** — Tell me which issues to fix
4. **No changes** — Review complete, no implementation needed

Please choose an option or provide specific instructions.

Important: Do NOT implement any changes until user explicitly confirms. This is a review-first workflow.


Resources

Reference files are in references/. Each step above specifies which files to load.

平台分布

Claude

34.64%
按下载量换算22

Codex

33.94%
按下载量换算21

Cursor

18.41%
按下载量换算12

Gemini CLI

10.16%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

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

继续浏览同类 Skills