This guide covers the best practices for using the cortex-works minimal stack in an AI-powered IDE.
Do not read the whole codebase at once. Use a three-level approach:
- L1 (Discover):
workspace_topologyto see roots, manifests, and language hints. - L2 (Map):
map_overvieworskeletonwithtarget_dirs=[...]to inspect only the relevant roots. - L3 (Slice):
deep_slice,read_source, or a targeted search once you know where to look.
In multi-root workspaces, use the [FolderName]/path/to/file convention.
This prefix now works across both AST and ACT tools, including:
cortex_code_explorerandcortex_symbol_analyzercortex_act_edit_ast,cortex_act_edit_data_graph,cortex_act_edit_markup,cortex_act_sql_surgerycortex_search_exact,cortex_fs_manage, andcortex_act_shell_exec(cwd=...)
If the argument is not absolute and does not use a prefix, it resolves against the primary workspace root.
For multi-root sessions, prefer arrays when the tool supports them:
target_dirs=["[frontend]", "[backend]"]formap_overviewandskeletonproject_path="[backend]"when using ACT search tools against one root
A good engineering session follows this loop:
-
Orientation
cortex_code_explorer(action="workspace_topology")cortex_code_explorer(action="map_overview", target_dirs=["[RootA]", "[RootB]"])
-
Analysis
cortex_symbol_analyzer(action="read_source", path="[RootA]/src/lib.rs", symbol_name="MyStruct")cortex_symbol_analyzer(action="find_usages", symbol_name="MyStruct", target_dir="[RootA]")
-
Safety
cortex_chronos(action="save_checkpoint", path="[RootA]/src/lib.rs", symbol_name="MyStruct", tag="pre-refactor")
-
Execution
- use
cortex_act_edit_astfor code changes - use
cortex_fs_managefor file creation, rename, move, copy, or delete
- use
-
Verification
cortex_act_shell_exec(run_diagnostics=true, cwd="[RootA]")cortex_chronos(action="compare_checkpoint", path="[RootA]/src/lib.rs", symbol_name="MyStruct", tag_a="pre-refactor", tag_b="__live__")
If you need to update a trait in crate-a and implement it in crate-b:
{
"name": "cortex_code_explorer",
"arguments": {
"action": "map_overview",
"target_dirs": ["[crate-a]"],
"search_filter": "trait"
}
}
{
"name": "cortex_code_explorer",
"arguments": {
"action": "deep_slice",
"target": "[crate-b]/src/impl.rs",
"single_file": true
}
}When changing a shared JSON config in one root:
{
"name": "cortex_chronos",
"arguments": {
"action": "save_checkpoint",
"path": "[config-root]/config.json",
"symbol_name": "root",
"tag": "before-json-fix"
}
}
{
"name": "cortex_act_edit_data_graph",
"arguments": {
"file": "[config-root]/config.json",
"edits": [{ "target": "$.v2_enabled", "action": "set", "value": "true" }]
}
}When editing and validating with the ACT tools only:
{
"name": "cortex_act_edit_ast",
"arguments": {
"file": "[backend]/src/lib.rs",
"edits": [{
"target": "function:handle_login",
"action": "replace",
"code": "pub fn handle_login() -> bool {\n true\n}\n"
}]
}
}{
"name": "cortex_act_shell_exec",
"arguments": {
"run_diagnostics": true,
"cwd": "[backend]"
}
}- Use
cortex_search_exactwhen you know the string:TODO(hero),Deprecated, or a specific error message. - When search can be scoped to one root, pass
project_path="[FolderName]".
cortex_act_edit_data_graph behaves differently for JSON and YAML:
| Operation | JSON | YAML |
|---|---|---|
Update existing key (set/replace) |
✅ | ✅ |
Insert a new top-level key (set) |
✅ (upserts) | ❌ use replace on parent |
Insert a nested key (set) |
✅ (upserts) | ❌ use replace on parent |
Delete a key (delete) |
✅ | ✅ |
Adding a new key to YAML: use action=replace targeting the parent object and supply the full updated object as the value.
TOML: not supported by cortex_act_edit_data_graph. Use cortex_fs_manage(action=write) to rewrite the whole file.
{
"name": "cortex_act_edit_data_graph",
"arguments": {
"file": "[config-root]/db.json",
"edits": [{ "target": "$.ssl", "action": "set", "value": "true" }]
}
}{
"name": "cortex_act_edit_data_graph",
"arguments": {
"file": "[config-root]/docker-compose.yaml",
"edits": [{
"target": "$.services.app",
"action": "replace",
"value": "{\"image\": \"myapp:v2\", \"ports\": [\"8080:80\"], \"restart\": \"always\"}"
}]
}
}Use cortex_act_batch_execute to collapse multiple round-trips into one. It runs operations sequentially and is ideal for:
- Several independent reads in one round-trip (topology + map_overview + search)
- Edit + verify patterns (edit → run_diagnostics)
- Explore + checkpoint + edit sequences
Rules:
- Do not nest
cortex_act_batch_executeinside itself. - If you include
cortex_mcp_hot_reload, make it the last operation because it restarts the worker. - Increase
max_chars_per_op(default 4000) when an operation returns large output (e.g.map_overview,deep_slice). - Use
fail_fast=truewhen later operations depend on earlier ones succeeding. parametersis optional per operation; omitted parameters default to{}.
Response shape: the tool returns a JSON object with:
total,passed,failed,skippedresults[], where each item hasindex,tool_name,success,output,output_chars, andtruncated
{
"name": "cortex_act_batch_execute",
"arguments": {
"fail_fast": true,
"max_chars_per_op": 8000,
"operations": [
{
"tool_name": "cortex_code_explorer",
"parameters": { "action": "map_overview", "repoPath": "/path/to/repo", "target_dirs": ["crates/cortex-act/src/act"] }
},
{
"tool_name": "cortex_act_edit_ast",
"parameters": {
"file": "[cortex-act]/src/act/shell_exec.rs",
"edits": [{ "target": "augment_unix_path", "action": "replace", "code": "fn augment_unix_path(...) { ... }" }]
}
},
{
"tool_name": "cortex_act_shell_exec",
"parameters": { "run_diagnostics": true, "cwd": "/path/to/repo", "timeout_secs": 60 }
}
]
}
}Typical response:
{
"total": 3,
"passed": 3,
"failed": 0,
"skipped": 0,
"results": [
{
"index": 0,
"tool_name": "cortex_code_explorer",
"success": true,
"output": "# WORKSPACE_TOPOLOGY ...",
"output_chars": 282,
"truncated": false
}
]
}- On Unix,
cortex_act_shell_execautomatically prepends~/.cargo/bin,~/.local/bin, and/usr/local/bintoPATHso tools likecargo,node, andpython3work even when launched from an IDE with a reduced PATH. run_diagnostics=trueauto-detects the build system from thecwdmanifest and runs the appropriate compiler check. Supported: cargo, tsc (tsconfig.json), go (go.mod), Maven (pom.xml), Gradle (build.gradle).- The hard
timeout_secskill is cross-platform:kill -9on Unix,taskkill /Fon Windows.