CMake — 18 Operations for AI Agents
CMake scripts decide how the C and C++ world compiles — targets, dependencies, toolchains. act101 surfaces targets and functions as structure, so agents trace why something links without spelunking through included modules.
This page is the canonical reference an AI coding agent uses to refactor, query, and analyze CMake code through the act MCP server. 18 operations available: 0 refactor, 18 query, 0 analysis. Each operation is callable from Claude Code, Cursor, Codex, OpenCode, or any MCP-compatible agent host. Click any operation for a stable anchor link suitable for citation.
Worked CMake examples
act101 reads a CMake file's function()/macro() definitions as function declarations named for the defined name, and reads three top-level command invocations — set(), add_executable(), and add_library() — as declarations too: the skeleton tags each unquoted_argument inside the call's argument list, so a two-argument call like set(NAME value) reports both the name and the value as separate declarations sharing one range. symbols covers the identical set of commands, but reports the set/add_executable/add_library entries as kind: unknown rather than variable, since it derives kind from the command node itself rather than from a stated kind capture. The unit of structure this grammar exposes is the top-level command invocation: act101 does not read project(), cmake_minimum_required(), or target_link_libraries() at all. Each example below is the verbatim output of the command shown, run against the file shown. Query outputs are pretty-printed with the timing block omitted.
Read function definitions and top-level commands as a skeleton
CMakeLists.txt builds a dataset pipeline: a register_stage helper function, a SCHEMA_VERSION variable, an ingest library, and a pipeline_cli executable.
$ act query skeleton CMakeLists.txt
Before
cmake_minimum_required(VERSION 3.20)
project(dataset_pipeline)
function(register_stage)
message(STATUS "registering pipeline stage")
endfunction()
set(SCHEMA_VERSION 7)
add_library(ingest ingest.cpp)
add_executable(pipeline_cli main.cpp)
target_link_libraries(pipeline_cli ingest)
Output
{
"type": "Skeleton",
"declarations": [
{
"kind": "function",
"name": "register_stage",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 4,
"column": 1,
"byte_offset": 64
},
"end": {
"file": "CMakeLists.txt",
"line": 6,
"column": 14,
"byte_offset": 149
}
},
"name_range": {
"start": {
"file": "CMakeLists.txt",
"line": 4,
"column": 10,
"byte_offset": 73
},
"end": {
"file": "CMakeLists.txt",
"line": 4,
"column": 24,
"byte_offset": 87
}
}
},
{
"kind": "variable",
"name": "SCHEMA_VERSION",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 8,
"column": 1,
"byte_offset": 151
},
"end": {
"file": "CMakeLists.txt",
"line": 8,
"column": 22,
"byte_offset": 172
}
},
"name_range": {
"start": {
"file": "CMakeLists.txt",
"line": 8,
"column": 5,
"byte_offset": 155
},
"end": {
"file": "CMakeLists.txt",
"line": 8,
"column": 19,
"byte_offset": 169
}
}
},
{
"kind": "variable",
"name": "7",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 8,
"column": 1,
"byte_offset": 151
},
"end": {
"file": "CMakeLists.txt",
"line": 8,
"column": 22,
"byte_offset": 172
}
},
"name_range": {
"start": {
"file": "CMakeLists.txt",
"line": 8,
"column": 20,
"byte_offset": 170
},
"end": {
"file": "CMakeLists.txt",
"line": 8,
"column": 21,
"byte_offset": 171
}
}
},
{
"kind": "variable",
"name": "ingest",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 10,
"column": 1,
"byte_offset": 174
},
"end": {
"file": "CMakeLists.txt",
"line": 10,
"column": 31,
"byte_offset": 204
}
},
"name_range": {
"start": {
"file": "CMakeLists.txt",
"line": 10,
"column": 13,
"byte_offset": 186
},
"end": {
"file": "CMakeLists.txt",
"line": 10,
"column": 19,
"byte_offset": 192
}
}
},
{
"kind": "variable",
"name": "ingest.cpp",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 10,
"column": 1,
"byte_offset": 174
},
"end": {
"file": "CMakeLists.txt",
"line": 10,
"column": 31,
"byte_offset": 204
}
},
"name_range": {
"start": {
"file": "CMakeLists.txt",
"line": 10,
"column": 20,
"byte_offset": 193
},
"end": {
"file": "CMakeLists.txt",
"line": 10,
"column": 30,
"byte_offset": 203
}
}
},
{
"kind": "variable",
"name": "pipeline_cli",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 12,
"column": 1,
"byte_offset": 206
},
"end": {
"file": "CMakeLists.txt",
"line": 12,
"column": 38,
"byte_offset": 243
}
},
"name_range": {
"start": {
"file": "CMakeLists.txt",
"line": 12,
"column": 16,
"byte_offset": 221
},
"end": {
"file": "CMakeLists.txt",
"line": 12,
"column": 28,
"byte_offset": 233
}
}
},
{
"kind": "variable",
"name": "main.cpp",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 12,
"column": 1,
"byte_offset": 206
},
"end": {
"file": "CMakeLists.txt",
"line": 12,
"column": 38,
"byte_offset": 243
}
},
"name_range": {
"start": {
"file": "CMakeLists.txt",
"line": 12,
"column": 29,
"byte_offset": 234
},
"end": {
"file": "CMakeLists.txt",
"line": 12,
"column": 37,
"byte_offset": 242
}
}
}
]
}
The skeleton reports register_stage as a function; set(SCHEMA_VERSION 7), add_library(ingest ingest.cpp), and add_executable(pipeline_cli main.cpp) each report two variable declarations at the same range — the target/variable name and its argument, such as SCHEMA_VERSION and 7 — since the query captures every unquoted argument in the call, not only the first.
List the same commands as symbols
The same file names ingest as a library target before linking it into pipeline_cli.
$ act query symbols CMakeLists.txt
Before
cmake_minimum_required(VERSION 3.20)
project(dataset_pipeline)
function(register_stage)
message(STATUS "registering pipeline stage")
endfunction()
set(SCHEMA_VERSION 7)
add_library(ingest ingest.cpp)
add_executable(pipeline_cli main.cpp)
target_link_libraries(pipeline_cli ingest)
Output
{
"type": "Symbols",
"symbols": [
{
"name": "register_stage",
"kind": "function",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 4,
"column": 10,
"byte_offset": 73
},
"end": {
"file": "CMakeLists.txt",
"line": 4,
"column": 24,
"byte_offset": 87
}
},
"visibility": "unknown"
},
{
"name": "SCHEMA_VERSION",
"kind": "unknown",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 8,
"column": 5,
"byte_offset": 155
},
"end": {
"file": "CMakeLists.txt",
"line": 8,
"column": 19,
"byte_offset": 169
}
},
"visibility": "unknown"
},
{
"name": "7",
"kind": "unknown",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 8,
"column": 20,
"byte_offset": 170
},
"end": {
"file": "CMakeLists.txt",
"line": 8,
"column": 21,
"byte_offset": 171
}
},
"visibility": "unknown"
},
{
"name": "ingest",
"kind": "unknown",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 10,
"column": 13,
"byte_offset": 186
},
"end": {
"file": "CMakeLists.txt",
"line": 10,
"column": 19,
"byte_offset": 192
}
},
"visibility": "unknown"
},
{
"name": "ingest.cpp",
"kind": "unknown",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 10,
"column": 20,
"byte_offset": 193
},
"end": {
"file": "CMakeLists.txt",
"line": 10,
"column": 30,
"byte_offset": 203
}
},
"visibility": "unknown"
},
{
"name": "pipeline_cli",
"kind": "unknown",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 12,
"column": 16,
"byte_offset": 221
},
"end": {
"file": "CMakeLists.txt",
"line": 12,
"column": 28,
"byte_offset": 233
}
},
"visibility": "unknown"
},
{
"name": "main.cpp",
"kind": "unknown",
"range": {
"start": {
"file": "CMakeLists.txt",
"line": 12,
"column": 29,
"byte_offset": 234
},
"end": {
"file": "CMakeLists.txt",
"line": 12,
"column": 37,
"byte_offset": 242
}
},
"visibility": "unknown"
}
]
}
symbols reports the same seven entries as skeleton, but the set, add_library, and add_executable pairs come back kind: unknown instead of variable, including ingest and its source ingest.cpp; only register_stage keeps the function kind in both queries.
Query
18 query tools, the same on every supported language. Descriptions live in the shared reference: /docs/query-tools.
callers control_flow data_flow definition diagnostics effect_closure effect_summary fix_auto get_type graph import_organize interface mutations references repo_outline skeleton symbols symbols_batch