/dvera:ct-test-loopfrom dvera
Use this skill to generate and run tests on an analyzed CT project and correct build failures through a feedback loop. In standalone runs, you must first ask the user whether to use requirements-based or AI-code-analysis generation mode.
Ships in dvera. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Primary request: Use this skill when repeating test generation and execution while correcting build errors.
If the CT installation path is missing or validation fails, do not continue. Show the notice below.
The CT installation could not be verified.
Provide the installation path to continue.
[Installation check]
• Checked CT installation path: {ctHome or "not configured"}
• Requirement: CT 2026.06 or later
• Note: A valid CT license is required to run CT.
[If CT is already installed]
• Please provide the full path to the CT installation folder.
Example: C:\Program Files\Suresoft\CT 2026
[If CT is not installed]
• Product and installation support: [email protected]
Entry: An analyzed CT project exists
Input (standalone): workspaces.ctson entry keyed by CWD -> projectName
Input (orchestrator-routed): in-memory state -> ct_resources.project_name
Output (orchestrator-routed): in-memory state update (status=test_success, test_results, coverage)
Execution mode:
ct-orchestrator (Phase 5): use in-memory state and run the default test generation flowprojectName from workspaces.ctson, then generate tests from a requirements document plus coding contextprojectName from workspaces.ctson, then let AI analyze the function source directly and generate tests without a requirements documentStandalone guard: At standalone entry, verify in two steps.
workspaces.ctson has no entry keyed by CWD -> stop immediately and tell the user "This directory is not registered as a CT project. Run ct-init-project first."ct_get_functions(projectName). If the function list is empty -> stop immediately and tell the user "Analysis is not complete. Run ct-analysis-loop first."
Precondition: Use the variables acquired in "Phase 0 Initial Setup" (ctHome/ctPython/ctTool/baseDir, etc.). In end-to-end entry, ct-init-project prepares them. In resume entry, ct-orchestrator prepares them. In standalone entry, acquire them via the procedure below.Before calling any test-generation tool (ct_create_test, ct_ai_generate_test), always run the two steps below.
ct-orchestrator and in-memory state was handed in -> orchestrator-routed mode.ct-orchestrator, which reads state.json and resumes from the phase matching the current status. (Presence/absence of in-memory state alone cannot distinguish "resuming an existing session in a fresh session," so when resume intent is present, do not fall through to standalone.)Forbidden:
ct_create_test or ct_ai_generate_test before the mode (orchestrator-routed / standalone-requirements / standalone-AI-code-analysis) is confirmed.ct-orchestrator" below. That sequence is for orchestrator-routed mode only.state.json, compiler_info.json, observations.jsonl, .conf, .ini, and .infojson.dump or json.dumpsstdout, stderr, pipes, or redirects, handle everything as UTF-8python -c. When paths, JSON, and Python code are nested in one string, encoding and escaping failures become much more likelystate.json, JSON payloads, and logs or metadata as absolute paths, and normalize to / when it is safe to do so/ normalization for paths passed to external process argv. Use argv lists by default, and only use / normalization when the target tool is known to accept it safelyLF as the default line ending for newly created internal management files such as state.json, compiler_info.json, and observations.jsonl. Preserve existing line endings when editing an existing filejson.dump(..., ensure_ascii=False) with tempfile.NamedTemporaryFile(delete=False, encoding="utf-8") or tempfile.gettempdir(), then pass it as ct_tool.py call ... --json "@{path}".
@- stdin only as a secondary input channel.ConvertTo-Json is a Windows-only auxiliary option; Bash heredoc/cat examples must not be the default payload path.argv lists over one-line string payloads.testRunSuccessbuild_succeeded, error_lines, and modifications together in test_loop.attempts[]toolchain_kind correction as an automatic Phase 5 repairtestRunSuccess == truect_ai_generate_test without user approval.if testRunSuccess == true:
collect results and stop
else:
classify build/log errors -> apply only allowed auto-fixes -> retry
project_name and working_directory exist and that the current phase is really Phase 5Standalone entry procedure:
ct-init-project/SKILL.md to acquire ctHome / ctPython / ctTool / baseDir. (Skip the workspace-selection step in standalone — step 2 below replaces it.)projectName
a. Use the Read tool to read {baseDir}/workspaces.ctson.
b. Parse the JSON. Schema: { "{sourceDir}": { "workspaces": [ { "path": "...", "projects": [...] } ] } }
c. Look up the entry keyed by the current CWD as sourceDir. Be careful with OS-specific path normalization (drive-letter case, slash direction).
d. Determine projectName from workspaces[0].projects (per the schema, workspaces[0] is the active one).
projects is empty, stop with "This directory is not registered as a CT project. Run ct-init-project first."ct_get_functions(projectName). If the function list is empty, treat it as standalone guard (2) and stop with "Analysis is not complete. Run ct-analysis-loop first."Phase 0 variables (acquired by ct-init-project in end-to-end entry, ct-orchestrator in resume entry, or step 1 above in standalone entry):
{ctPython}: Python executable path based on ct_get_env.pythonPath{ctTool}: ct_tool.py execution pathskillResourceRoot: autoconfig path from ct_get_env.skillResourceRootmetaDir: metadata path from ct_get_env.metaDirCT functions (used in Phase 5):
ct_get_functions(projectName) - function listct_find_functions(projectName, query) - similarity-based candidate search for standalone requirements-based modect_create_test(projectName, target) - generate testsct_ai_generate_test(projectName, signatureHash, specs?) - AI test generation. specs is an array of requirement strings. With specs, use requirements-based generation; without it, use CT built-in AI code analysisct_execute_test(projectName, executeAll) - execute testsct_get_test_results(projectName) - retrieve resultsct_get_coverage(projectName) - retrieve coveragect_generate_report(projectName, outputDir, formats?) - generate reports (optional). formats accepts one or more of pdf, html, xlsx, xls, docx, doc, pptx, ppt (defaults to ["pdf"])ct_set_link_flags(projectName, linkFlags) - modify link flagsct_set_compile_flags(projectName, compileFlags) - modify compile flagsct_modify_toolchain(toolchainId, iniFilePath?) - apply ini changes when correcting toolchain_kind. After this call, do not call ct_set_project_toolchain. An ini-only call does not require confType or language, and those parameters do not affect it.ct_create_test target rule: use the official target untested_functions for untested functions. Common aliases such as untested and untested_function are accepted when no function name matches.
ct-orchestrator-routed test mode core sequence (default test generation; apply only when "Entry Mode Determination" confirmed orchestrator-routed mode):
ct_get_functions -> stop if the function count is 0ct_create_test(target="{function_name}")
ct_execute_test(executeAll=true)
b. If testRunSuccess == true -> the build succeeded -> run ct_get_test_results + ct_get_coverage -> stop immediately. Even if individual tests are error or fail, do not analyze logs
c. If testRunSuccess == false -> the build failed or a pilot/runtime failure -> classify errors from logs:
log/build/{ModuleName}/*.log.txtlog/build/link.log.txtlog/engine.log
Classification actions:undefined reference -> add -l to ct_set_link_flags-I to ct_set_compile_flagsconstexpr, nullptr, or char16_t in system headers -> toolchain_kind mismatch. Correct toolchain_kind in the ini to the matching host GCC version (Linux requires the _64 suffix, for example 95_64), then run ct_modify_toolchain(toolchainId, iniFilePath) -> rerun ct_analyze -> rerun ct_execute_test. Do not call ct_set_project_toolchaintestrun.exe exists and link.log is empty) but runtime execution does not start -> treat it as a runtime failure, not a build failure. Do not apply link/include flag fixes. Use canonical diagnostic guidance from the installed CT/DVERA environment; if unavailable or the failure persists, stop and report the evidence to the user.In standalone execution, immediately after passing the standalone guard (project registration + analysis completion), ask the user how tests should be generated.
How would you like to generate the tests?
1. Requirements-based test generation
- Generate spec-driven tests using requirements documents plus coding context
- Preserves design intent, boundary values, and exception handling in the test spec
2. AI code analysis-based test generation
- AI analyzes the function source directly without requirements documents
- Useful for legacy code or when no requirements document exists
-> If the user selects 1: proceed to "Standalone execution procedure (requirements-based)" -> If the user selects 2: proceed to "Standalone execution procedure (AI code analysis-based)"
Follow the procedure below only in standalone mode. Do not run this inside the ct-orchestrator-routed test mode.
Use the projectName identified in step 2 of the standalone entry procedure above.
Call ct_find_functions with the function name or signature mentioned by the user as the query.
Branch on result:
totalCount == 0: function not found -> ask the user for the exact function name againtotalCount == 1: confirm automatically without asking the usertotalCount >= 2: show the candidate list and ask the user to chooseRemember the selected function's signatureHash, signature, and sourceFile.
Priority:
requirements/, req/, specs/, spec/, docs/, doc/, and the repository root .*.md, *.txt, *.rst, *.pdf, *.docx, *.xlsx, *.html, *.htmrequirement, req, spec, srs, or irsmd, txt, rst, html) directly. For binary formats (pdf, docx, xlsx), read them only if the tool supports it. Otherwise show the file path and ask the user to provide the relevant contentBranch on file count:
0: ask the user for the requirements document path1~5: use them as-is6+: show the list and ask the user to chooseBuild the specs by combining the two sources below. Split distinct requirements into separate strings when possible.
A. Coding context - content from the current conversation that must be reflected in tests:
B. Requirements documents - extract only content related to the target function from the collected documents:
After writing the specs, show the list to the user and ask for confirmation or edits. If the user provides feedback, apply it, show the specs again, and reconfirm. Proceed only after the user approves the specs.
Call ct_ai_generate_test with the approved specs list and signatureHash.
ct_ai_generate_test {
"projectName": "{identified projectName}",
"signatureHash": "{signatureHash of the confirmed function}",
"specs": [
"{user-approved spec 1}",
"{user-approved spec 2}"
]
}
targetFunctionCount: number of target functions processed (1 in this flow)generatedTestCount: total number of generated test filesgeneratedTestFiles: list of generated test file namesmessage: server messageIn this mode, AI analyzes the function source directly and generates tests without a requirements document. Do not run this inside the ct-orchestrator-routed test mode.
Use the projectName identified in step 2 of the standalone entry procedure above.
Call ct_find_functions with the function name or signature mentioned by the user as the query.
Branch on result:
totalCount == 0: function not found -> ask the user for the exact function name againtotalCount == 1: confirm automatically without asking the usertotalCount >= 2: show the candidate list and ask the user to chooseRemember the selected function's signatureHash.
Call the CT built-in AI test generation function (ct_ai_generate_test). AI analyzes function source code and type information, generates code-based tests, and automatically corrects compile errors through its internal feedback loop.
ct_ai_generate_test {
"projectName": "{identified projectName}",
"signatureHash": "{signatureHash of the confirmed function}"
}
Precondition: the CT AI server must already be configured. If not, report the error to the user and stop.
targetFunctionCount: number of target functions processed (1 in this flow)generatedTestCount: total number of generated test filesgeneratedTestFiles: list of generated test file namesmessage: server messageForbidden in AI code analysis mode:
totalCount == 1. Confirm automaticallyStandalone forbidden rules:
totalCount == 1. Confirm automaticallyct_ai_generate_test without user confirmation for the specs in the requirements-based modeSingle-change recording rules:
modifications as an array for each attemptdetail, diagnosis, and intent inside modifications[0]detail is the required string for observation-record collectiondiagnosis or intenttestRunSuccess == true are not observation-record targetsImportant: build errors vs test result errors must be distinguished
testRunSuccess == true -> the build succeeded. Even if individual tests are error or fail, this is a test execution result. Do not analyze logs. Report the result and finishtestRunSuccess == false -> the build failed. Only in this case should you analyze logs and try fixesNote: ct_set_compile_flags applies only to analysis preprocessing and is not passed to the test build command. Macros or types needed for the build must be resolved at the conf level or included in the preprocessing result.
Forbidden:
testRunSuccess == true, do not read logs, analyze them, or attempt fixes. Report the result and finishct_set_compile_flags. Those flags are not passed to the build, so resolve it through conf changes instead{
"status": "test_success",
"test_loop": {
"attempt_count": 2,
"max_attempts": 5,
"loop_epoch": 1,
"target_functions": ["Board_init"],
"attempts": [
{
"attempt": 1,
"result": "failed",
"verdict": "stalled",
"build_succeeded": false,
"error_lines": ["undefined reference to `Board_init`"],
"modifications": [
{
"action": "link_flag_add",
"detail": "-lboard",
"diagnosis": "The board library symbol is missing during the test link step",
"intent": "Add the missing library link flag"
}
]
},
{
"attempt": 2,
"result": "success",
"verdict": "improved",
"build_succeeded": true,
"error_lines": [],
"modifications": []
}
]
},
"test_results": {
"testRunSuccess": true,
"total": 1,
"passed": 1,
"failed": 0,
"tests": [{ "testName": "Board_init_TC1", "suiteName": "GeneratedSuite", "status": "Success" }]
},
"coverage": { "statement": "100%", "branch": "100%", "mcdc": "N/A" }
}
Minimum validator contract:
test_loop exists, it must contain attempt_count, loop_epoch, and attempts[]verdict is recorded, the only allowed values are improved, stalled, and regressedmodifications length is 1, modifications[0] must be an object, and detail, diagnosis, and intent must be non-empty strings
Documentation conventions:coverage at the top level, not under test_resultscoverage only when status=test_success and test_results.testRunSuccess=truetest_results.tests as an example array of { testName, suiteName, status } objectsmodifications array and omit diagnosis and intentDetailed error classification, loop control, and final state validation are supplied with the installed CT/DVERA environment. Use its canonical documentation when available. If it is unavailable, do not execute or modify CT test assets; summarize the prepared test intent and direct the user to [email protected].
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
14 skills in this plugin
/ct-analysis-loopUse this skill during the CT project analysis phase to classify errors, repeat conf or toolchain fixes, and continue until analysis succeeds./ct-extract-macroUse this skill to extract the target compiler's compiler-default macros and build the shared environment analysis fields used during CT project preparation./ct-init-projectUse this skill to run the CT full pipeline from Phase 0 initial setup through macro extraction, conf and toolchain creation, analysis, testing, and observation-record collection, or to perform only the project-preparation stage.npx claudepluginhub suresofttechnologies/dvera-plugin --plugin dvera