/dvera:ct-analysis-loopfrom dvera
Use this skill during the CT project analysis phase to classify errors, repeat conf or toolchain fixes, and continue until analysis succeeds.
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 configuration fixes and re-analysis after an analysis failure, or when recording functions_found in state.
Entry: status is project_created
Input: state.json -> ct_resources.* + (for conversion, top-level conf_path; keep artifacts.conf_path as a mirror)
Output: state.json (status=analysis_success)
Execution mode: In-memory state when called through ct-orchestrator / one-time state.json read in standalone mode
Standalone guard: In standalone mode, read state.json and confirm that status is project_created.
state.json is missing or status is not project_created -> stop immediately and tell the user to run ct-init-project first to complete project preparationct_resources.project_name, ct_resources.working_directory) are missing, analysis cannot proceedconversion, if top-level conf_path is missing or the artifacts.conf_path mirror is not kept with it, treat it as a Phase 2/3 regression target
conf path contract:conf_pathartifacts.conf_path must also be kept, and both values must point to the same absolute path
Precondition: Use the bootstrap variables acquired in Phase 0. In end-to-end entry, ct-init-project prepares them. In resume entry, ct-orchestrator prepares them. Even in standalone mode, run the bootstrap procedure below first.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.analysis_loop.attempts[]modifications as an array at all times, and when an attempt succeeds, write functions_found inside the last successful attempt objectconversion, update fingerprints.conf_hash immediately in the same attemptlog/pa/PA_*.log, log/parse/*.elog, and log/preprocess/*.plogfunctions_found at the top level or directly under analysis_loopGet-ChildItem -Recurse over the whole working directory on the first failure diagnosticct_set_project_toolchain again after ct_modify_toolchaincs_replace_code is required, or if phase regression is needed, stop and reconfirm the decision.functions_found == 0 but the source likely contains real function definitions, do not mechanically finalize the result without rechecking.{
"attempt": 2,
"result": "success",
"functions_found": 12,
"error_lines": [],
"modifications": []
}
conversion, confirm that top-level conf_path and the artifacts.conf_path mirror point to the same absolute pathattempt object first: attempt, result, error_lines, modificationsconf_hash within the same attemptStandalone bootstrap procedure:
bootstrap.ct_home exists in state.json, use that value.
{ctHome}/python/python.exe exists. Linux/Mac: {ctHome}/python/python3 existsctTool candidate can be found with glob({ctHome}/plugins/*/scripts/ct_tool.py)bootstrap.ct_home is missing or validation fails, check the OS-specific default installation path once.C:\Program Files\Suresoft\CT 2026$HOME/Suresoft/CT 2026ctHome with the standard prompt below.{ctHome}/python/python.exe exists. Linux/Mac: {ctHome}/python/python3 existsctTool candidate can be found with glob({ctHome}/plugins/*/scripts/ct_tool.py)ctHome with the standard prompt 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]
2. `ctPython` candidate: Windows -> `{ctHome}/python/python.exe`, Linux/Mac -> `{ctHome}/python/python3`
3. `ctTool` candidate: `glob({ctHome}/plugins/*/scripts/ct_tool.py)`
4. Call `ct_get_env` to acquire `pythonPath`, `skillResourceRoot`, `toolRoot`, `metaDir`, and `baseDir`
```bash
{ctPython} {ctTool} call ct_get_env --json "{}"
ctPython, ctTool, and skillResourceRoot from the returned valuessessionsBase is known, search for the latest session's state.json under {sessionsBase}/
Bootstrap variables (acquired in Phase 0; end-to-end entry via ct-init-project, resume entry via ct-orchestrator, or by the standalone procedure above):
{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.metaDirsessionsBase: workspace base path from {baseDir}/sessions/ (derived)CT functions (used in Phase 4):
ct_analyze(projectName) - run analysisct_get_functions(projectName) - fetch the function list on successct_modify_toolchain(toolchainId, confFilePath?, confType?, systemHeaders?, language?) - apply conf or header changes. After this call, do not call ct_set_project_toolchain. Reflect the change by rerunning ct_analyzect_set_compile_flags(projectName, compileFlags) - adjust flagsct_get_toolchain(toolchainId) - retrieve the current toolchain settings for rollbackLanguage contract:
"C" or "CPP" value from state.source_info.language.confFilePath to ct_modify_toolchain, also send confType as "C" or "CPP".systemHeaders, also send language as "C" or "CPP".INVALID_PARAMS, do not guess. Ask the user to choose 1) C 2) CPP, retry at most once, and stop Phase 4 if it still fails.iniFilePath) are unaffected by confType or language.Core sequence:
.original in conversion, and save the initial statect_analyze:
ct_analyze returns success=true and ct_get_functions returns a non-empty list -> write functions_found=N in the successful attempt and exitct_analyze returns success=true but ct_get_functions returns 0 functions while source_info.file_count >= 1 and at least one source file contains a real function definition (grep for ^\w[\w\s*]*\(.*\)\s*\{ or an equivalent C function-body pattern) -> treat this as a Phase 4 failure, not a success. Run the functions_found=0 recovery checklist below before starting a retry attemptlog/pa/PA_*.loglog/parse/*.elog (exists only on failure)log/preprocess/*.plog (exists only on failure)log/fe/.work/preprocess/*.i
Use limited extraction with PowerShell Select-String + Select-Object -First N or an equivalent bounded grep + head pattern
Keep the first lookup to those patterns only; do not recursively list the whole working directory.
b. Classify errors by priority: infrastructure > memory > system headers > preprocessing > conf-symbol
c. Apply fixes: edit conf -> ct_modify_toolchain with confType/language -> ct_analyze rerun / or update compileFlags
d. Judge progress: improved (15% decrease), stalled, or regressed (10% increase) -> rollback up to 2 timesFingerprint rules:
conversion, recalculate fingerprints.conf_hash immediately within the same attempthost mode does not enforce conf or ini fingerprintsSingle-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 intentverdict=improved/stalled/regressed is later used by ct-kb-update to build positive or negative observation recordsProduct guidance loading: After the first failure, use the canonical diagnostic guidance supplied by the installed CT/DVERA environment when available. If it is unavailable, do not guess a product-specific recovery action; report the evidence collected so far and stop.
Quick reference (always use the ref documents as the actual decision basis):
identifier "X" is undefined + keyword -> cs_ignore_single_keyword=Xidentifier "X" is undefined + type -> cs_builtin_declaration=typedef ... X;could not open source file + system header -> add ct_modify_toolchain(systemHeaders, language=source_info.language)could not open source file + project header -> add -I through ct_set_compile_flagsPhase regression: setting application failure -> P3, conf root cause -> P2, polluted macros -> P1, same reason twice -> user escalation
Forbidden:
Select-String + Select-Object -First Ncs_replace_code with other edits in the same attemptct_set_project_toolchain after ct_modify_toolchain. Reflect toolchain edits by rerunning ct_analyze#error "Failed to match a default include file" inside a vendor system header), the fix belongs in a Phase 1/2 regression - rerun ct-extract-macro with the correct dump flag, regenerate conf, then retry analysis. Injecting cs_define_macro_name=__TARGET_MCU__=1 directly into Phase 2 output to get past the symptom is forbidden; it hides the root cause and corrupts the observation record for ct-kb-update.functions_found=0 Recovery ChecklistWhen ct_analyze returns success but ct_get_functions yields 0 functions, and the source clearly contains function definitions, do not finalize the phase. Work through the checklist below in order and record the finding in error_lines for the next attempt.
functions_found=0 legitimately. Otherwise continue.{working_directory}/src/preprocessed/<name>_1.i.c (or obj/<name>.c.*/src/preprocessed/). If the file is suspiciously small (for a non-trivial source, under ~30 lines often means every #include collapsed to nothing), the root cause is typically a missing target-MCU or vendor macro - the vendor's device header hit its fall-through #error and stopped expansion.target_macros.txt line count to what the real compiler would emit. Real dumps from GCC/Clang/cl430/iccarm typically produce 40~200+ entries. If your target_macros.txt has ~15 entries and lacks __VERSION__, __EDG_VERSION__, __TI_COMPILER_VERSION__, or the equivalent, Phase 1 is the root cause - regress to Phase 1 and use the compiler's documented macro-dump command. Do not patch the conf here..plog has ERROR2007 / #error / catastrophic error? Read the .plog for the failing source with bounded extraction. A catastrophic error at line N of a vendor header (e.g., msp430.h, stm32f4xx.h) that says "Failed to match a default include file" is definitive evidence of missing target macros - regress to Phase 1.env_profile.system_headers path exists and contains real header files (ls {path}/*.h | head). A system header path that exists but is empty is a Phase 1 header-collection bug.Phase regression decision matrix for functions_found=0:
| Checklist finding | Regression target | Reason |
|---|---|---|
target_macros.txt missing __VERSION__/vendor version macros | Phase 1 | dump flag was wrong or macros were hand-written |
.plog shows "Failed to match a default include file" | Phase 1 | target-MCU macro missing from dump |
env_profile.system_headers path exists on disk but contains no headers | Phase 1 | header-collection logic picked the wrong directory |
Preprocessed .i is near-empty but macros and system-header contents look correct | Phase 2 or 3 | conf merge or systemHeaders wiring |
| Source genuinely has no functions | Finalize | functions_found=0 is a legitimate result |
{
"status": "analysis_success",
"analysis_loop": {
"attempt_count": 2,
"max_attempts": 5,
"loop_epoch": 1,
"attempts": [
{
"attempt": 1,
"result": "failed",
"verdict": "stalled",
"error_lines": ["identifier \"__packed\" is undefined"],
"modifications": [
{
"action": "conf_add",
"detail": "cs_define_macro_name=__packed",
"diagnosis": "__packed is an undefined compiler extension keyword in the host environment",
"intent": "Define it as an empty macro so it is ignored"
}
]
},
{
"attempt": 2,
"result": "success",
"functions_found": 12,
"error_lines": [],
"modifications": []
}
]
}
}
Note: Do not turn attempt_count into a separate object like {"phase1":1,"phase2":1,...}. It must stay inside analysis_loop.
Minimum validator contract:
analysis_loop 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
Required location: Record functions_found inside the last successful attempt object in analysis_loop.attempts[]. Do not place it at the top level or directly under analysis_loop.
Documentation convention: Keep attempt, result, error_lines, and modifications in example JSON. For multi-change attempts, keep only the modifications array and omit diagnosis and intent.Detailed recovery rules and state validation are supplied with the installed CT/DVERA environment. Use its canonical documentation when available. If it is unavailable, do not guess or execute product-specific recovery steps; collect the inputs and evidence, explain the intended workflow, 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
npx claudepluginhub suresofttechnologies/dvera-plugin --plugin dvera14 skills in this plugin
/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./ct-kb-updateUse this skill to append single-change attempt results to `observations.jsonl`. It is called by `ct-init-project` or `ct-orchestrator` immediately after the CT-apply full pipeline completes./ct-make-confUse this skill to generate the conversion analysis `.conf` and toolchain metadata (`.ini`, `.info`) from extracted target macros and `compiler_info`, and to record fingerprints./ct-openLaunch CT with the current workspace. Use when you need to inspect the project visually in CT IDE during agent work./ct-orchestratorUse this skill to continue an existing `state.json` session and decide whether to resume `ct-init-project`, `ct-analysis-loop`, or `ct-test-loop` from the current status.