CFDesktop: Command for Claude Code

.claude/commands/testing.md

testing is a command for Claude Code from Awesome-Embedded-Learning-Studio/CFDesktop. It costs 0 tokens per session (924 once invoked), scanned A, original, MIT.

A command that examines a C or C++ module and suggests tests for it. It checks existing test files, public interfaces, edge cases, thread-safety concerns, and the project's GoogleTest and CMake patterns.

In plain words
What is it for?
Use it when adding or changing a module to suggest unit tests, inspect current coverage, and connect the recommendations to existing test targets.
Why use it?
It helps reveal untested code paths and turns them into a prioritised testing plan. The suggestions cover normal behaviour, invalid input, boundaries, and resource or concurrency risks.

Command for Claude Code

Written for Claude Code: installed under .claude/.

This is Awesome-Embedded-Learning-Studio/CFDesktop's own configuration. It tells Claude Code how to work on CFDesktop itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything CFDesktop configures →

Reuse

Borrowing it

Nothing to install: this file belongs to Awesome-Embedded-Learning-Studio/CFDesktop. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/Awesome-Embedded-Learning-Studio/CFDesktop/main/.claude/commands/testing.md
Clone the repo
git clone --depth 1 https://github.com/Awesome-Embedded-Learning-Studio/CFDesktop

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for testing

README.md
[![agentmods](https://agentmods.dev/badge/commands/awesome-embedded-learning-studio/cfdesktop/testing/github.svg)](https://agentmods.dev/commands/awesome-embedded-learning-studio/cfdesktop/testing)
Your own site
<a href="https://agentmods.dev/commands/awesome-embedded-learning-studio/cfdesktop/testing"><img src="https://agentmods.dev/badge/commands/awesome-embedded-learning-studio/cfdesktop/testing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for testing

Your own site · 80×15
<a href="https://agentmods.dev/commands/awesome-embedded-learning-studio/cfdesktop/testing"><img src="https://agentmods.dev/badge/commands/awesome-embedded-learning-studio/cfdesktop/testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 924 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00924
Opus 5.5 $0.00000 $0.00370
Sonnet 5.5 $0.00000 $0.00185
Haiku 4.5 $0.00000 $0.00092

Measured 2mo ago against content hash 349b5a8ac3c4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/testing.md · 130 lines

How it starts

The opening of the file, as written. The whole thing — 130 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/testing — 测试覆盖建议

为新增或修改的代码建议测试用例,参考现有测试模式。

触发方式

  • /testing <模块路径> — 建议测试用例
  • /next-step 或 /optimize 衔接

工作流程

Step 1: 分析目标代码

  1. 读取源文件,识别公共 API 接口:

    • 公共方法(public methods)
    • 信号和槽(signals/slots)
    • 枚举和常量
    • 模板函数/类
  2. 识别边界情况:

    • 空输入、零值、最大值
    • 无效输入、越界访问
    • 资源限制(内存、文件句柄)
  3. 识别线程安全问题:

    • 锁自由数据结构
    • 异步操作
    • 共享状态访问

Step 2: 检查现有测试覆盖

  1. 在 test/<module>/<component>/ 查找已有测试文件
  2. 读取已有测试,理解当前覆盖范围
  3. 识别未覆盖的代码路径

Step 3: 参考现有测试模式

文件模式 (test/<module>/<component>/<component>_test.cpp):

/**
 * @file    <component>_test.cpp
 * @brief   Test coverage for <Component>.
 */
#include <gtest/gtest.h>
#include "<component>.h"

TEST(<Component>Suite, BasicFunctionality) {
    // Arrange
    // Act
    // Assert
}

CMake 模式 (test/<module>/CMakeLists.txt):

add_gtest_executable(<component>_test
    <component>/<component>_test.cpp
    LINK_LIBRARIES <target> GTest::gtest GTest::gtest_main
    LABELS "module;unit;component"
)

Step 4: 测试建议分级

P0 — 必须有 (Critical Path)
  • 构造函数/析构函数基本功能
  • 主要用例(happy path)
  • 错误处理(无效输入)
P1 — 应该有 (Boundary)
  • 空输入、零值、最大值
  • Off-by-one 边界
  • 资源限制
P2 — 可选有 (Integration/Regression)
  • Qt 框架交互(Signal/Slot)
  • 跨组件交互
  • 线程安全测试
  • 性能回归测试

Step 5: 输出格式 (中文)

# 测试建议: <module/component>

## 现有测试状态
- 已有测试文件: (列出或 "无")
- 覆盖率评估: X%
- 未覆盖的关键路径: ...

## 建议新增测试

### P0 — 必须
```cpp
// TEST(<Component>Suite, ConstructorInitializesCorrectly)
TEST(<Component>Suite, ConstructorInitializesCorrectly) {
    // Arrange & Act
    <Component> obj{/* params */};
    // Assert
    EXPECT_EQ(obj.<getter>(), expected);
}

P1 — 应该

(测试用例骨架)

P2 — 可选

(测试用例骨架)

测试文件位置

  • 建议路径: test/<module>/<component>/<component>_test.cpp
  • CMakeLists.txt 修改:
add_gtest_executable(<component>_test ...)

预估工作量

  • P0 测试数量: N
  • P1 测试数量: N
  • P2 测试数量: N
  • 预估耗时: X minutes

## 模块特定注意事项

- **base/ 工具库**: header-only,链接 `cfbase_headers` + `GTest`
- **ui/ 控件**: 需要 `QApplication`,链接 `cfui` + `Qt6::Widgets` + `Qt6::Gui`
- **desktop/**: 需要完整 `CFDesktop_shared` + `Qt6::Widgets`
- **Signal/Slot 测试**: 需要 `Qt6::Test`,使用 `QSignalSpy`

Read the full file on GitHub · 130 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 130 lines · 0 tokens per session scan A 349b5a8ac3c4

Subscribe to this mod's changes

testing is a command published in the GitHub repository Awesome-Embedded-Learning-Studio/CFDesktop (11 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 924 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.