/arcanon:map [view|full]from arcanon
Build or refresh the service dependency map by scanning linked repos with Claude agents. Use when the user runs /arcanon:map to build the impact map for the first time or re-scan after changes.
Ships in arcanon. Installing the plugin adds it to Claude Code.
This command scans linked repositories using Claude agents to discover services, API endpoints, and connections between them. Results are stored in SQLite and visualized in a web UI.
Core task: Read each repo's code → extract services and connections → confirm with user → save.
/arcanon:map — scan repos and build the dependency graph/arcanon:map view — just open the graph UI (no scanning)/arcanon:map full — force full re-scan of all filesview flag: Open Graph UI and Exitsource ${CLAUDE_PLUGIN_ROOT}/lib/help.sh
arcanon_print_help_if_requested "$ARGUMENTS" "${CLAUDE_PLUGIN_ROOT}/commands/map.md" && exit 0
source ${CLAUDE_PLUGIN_ROOT}/lib/worker-client.sh
worker_running || bash ${CLAUDE_PLUGIN_ROOT}/scripts/worker-start.sh
PORT=$(cat ~/.arcanon/worker.port)
# Cross-platform open
if command -v xdg-open &>/dev/null; then xdg-open "http://localhost:${PORT}"
elif command -v open &>/dev/null; then open "http://localhost:${PORT}"
else echo "Open http://localhost:${PORT} in your browser"; fi
Print "Graph UI opened" and stop. Do not proceed to scanning.
Before scanning, ensure the project has a name stored in arcanon.config.json.
Read existing config:
PROJECT_NAME=""
if [ -f arcanon.config.json ]; then
PROJECT_NAME=$(node --input-type=module -e "
import fs from 'fs';
const c = JSON.parse(fs.readFileSync('arcanon.config.json', 'utf8'));
if (c['project-name']) console.log(c['project-name']);
")
fi
If PROJECT_NAME is empty, ask the user using AskUserQuestion:
What is this project called? (e.g., "my-platform", "acme-backend")
Then write the entered name to config:
node --input-type=module -e "
import fs from 'fs';
const configPath = 'arcanon.config.json';
const config = fs.existsSync(configPath)
? JSON.parse(fs.readFileSync(configPath, 'utf8'))
: {};
config['project-name'] = '${PROJECT_NAME}';
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
"
If PROJECT_NAME already exists, print: Project: ${PROJECT_NAME} and continue.
Find repos to scan from two sources:
From config:
[ -f arcanon.config.json ] && node --input-type=module -e "
import fs from 'fs';
const c = JSON.parse(fs.readFileSync('arcanon.config.json', 'utf8'));
(c['linked-repos'] || []).forEach(r => console.log(r));
"
From parent directory:
source ${CLAUDE_PLUGIN_ROOT}/lib/linked-repos.sh
list_linked_repos
Combine, deduplicate, and present to the user:
Found these repos:
- ../api (configured)
- ../auth (configured)
- ../sdk (discovered)
Confirm? (yes / edit / no)
Save confirmed list to arcanon.config.json.
Capture the project root at this point:
PROJECT_ROOT="$(pwd)"
This is the main task. Each repo is scanned in two phases for accuracy and efficiency.
Scan mode determination:
If this is the first scan (no existing data in the database), proceed with a full scan automatically — no confirmation needed.
If full subcommand is present AND existing scan data exists, ask the user before proceeding:
Existing scan data found (N services, M connections).
A full re-scan will delete all existing data and rebuild from scratch.
Proceed with full re-scan? (yes / no — incremental scan instead)
If the user says no, fall back to incremental mode (only scan repos with changes).
If full is NOT present, use incremental mode — only scan repos with changes since last scan.
For each repo:
Check if scan is needed (skip for incremental mode):
LAST_COMMIT=$(git -C "${REPO_PATH}" rev-parse HEAD 2>/dev/null)
Compare with the repo's last_scanned_commit from the database. If they match and mode is incremental, ask the user:
No changes detected in <repo> since last scan.
Skip this repo? (yes / no — force re-scan this repo)
Stage 1 — Discovery (fast, reads only structure files): Read the discovery prompt template using the Read tool:
Read(${CLAUDE_PLUGIN_ROOT}/worker/scan/agent-prompt-discovery.md)
Replace {{REPO_PATH}} with the absolute path. Spawn a quick agent:
Agent(
prompt="<filled discovery prompt>",
subagent_type="Explore",
description="Discover <repo-name> structure"
)
The agent returns a JSON with languages, frameworks, service_hints, route_files, etc. This takes seconds.
Stage 2 — Deep scan (reads source code, targeted by discovery):
Select the per-type template based on the repo's type — this mirrors detectRepoType() in worker/scan/manager.js:
agent-prompt-infra.md — Terraform (*.tf), Kustomize/Helm (kustomization.yaml, Chart.yaml, helmfile.yaml), an overlays/ or terraform/ directory, or a docker-compose.* with no service entry pointagent-prompt-library.md — a package manifest that exports but has no start/serve entry point (package.json with main/exports/types but no start script; pyproject.toml [project] without [project.scripts]; Cargo.toml [lib] without [[bin]])agent-prompt-service.md — everything else (the default)Read the shared rules and the selected per-type template using the Read tool:
Read(${CLAUDE_PLUGIN_ROOT}/worker/scan/agent-prompt-common.md)
Read(${CLAUDE_PLUGIN_ROOT}/worker/scan/agent-prompt-service.md) # or -library.md / -infra.md per the type above
Compose the prompt from the per-type template: replace {{COMMON_RULES}} with the contents of agent-prompt-common.md, {{REPO_PATH}} with the absolute path, and {{DISCOVERY_JSON}} with the Stage 1 JSON output. The common rules reference {{SCHEMA_JSON}} — point it at ${CLAUDE_PLUGIN_ROOT}/worker/scan/agent-schema.json (the agent reads the schema from there). Spawn a focused agent:
Agent(
prompt="<filled deep scan prompt with discovery context>",
subagent_type="Explore",
description="Deep scan <repo-name> for services"
)
The agent uses the discovery context to focus on relevant files — route files, handler files, proto files — instead of scanning everything.
Extract the JSON from between the ``` markers. Validate the findings.
Print progress:
Scanning 1/N: api...
Stage 1: discovered (python, fastapi, 2 services, 5 route files)
Stage 2: scanned (2 services, 5 connections, 8 endpoints exposed)
Scanning 2/N: auth... (skipped — no changes)
Collect all findings. Group by confidence (high/low).
After all repos are scanned, run a single reconciliation pass over all collected findings to correct misclassified external crossings.
Build the known-services set:
Collect every service.name from every repo's scan findings:
const knownServices = new Set();
for (const finding of allFindings) {
for (const service of (finding.services || [])) {
knownServices.add(service.name);
}
}
Downgrade external to cross-service:
For every connection across all findings: if crossing === "external" AND target is in knownServices, change crossing to "cross-service". Capture the original value on the connection object so Step 5 can write an enrichment_log audit row after endScan resolves the connection's DB id:
let _reconciledCount = 0;
for (const finding of allFindings) {
for (const conn of (finding.connections || [])) {
if (conn.crossing === 'external' && knownServices.has(conn.target)) {
// Capture original value BEFORE mutation for the enrichment audit log.
// The `_reconciliation` field rides through the JSON write-then-read
// round-trip in Step 5 (it's a plain own enumerable property).
conn._reconciliation = {
from: 'external',
to: 'cross-service',
reason: 'target matches known service: ' + conn.target,
};
conn.crossing = 'cross-service';
_reconciledCount++;
}
}
}
if (_reconciledCount > 0) {
console.log('Reconciliation: ' + _reconciledCount + ' connection(s) reclassified external → cross-service');
}
If no changes, print nothing.
All findings must be confirmed before saving.
Show high-confidence findings as a batch:
Services found:
- user-api (repo: api, language: typescript)
- auth-service (repo: auth, language: python)
Connections:
- user-api → auth-service [REST POST /auth/validate]
- user-api → billing [REST POST /billing/charge]
Confirm these? (yes / edit / no)
For low-confidence findings (max 10), ask individually:
Uncertain: Is user-api calling config-service at GET /config?
Evidence: "const url = getConfig().configEndpoint"
(yes / no / skip)
First, write the confirmed findings JSON to a temp file to avoid shell escaping and ARG_MAX issues:
# Write findings to temp file (use Write tool, or echo with heredoc)
FINDINGS_FILE=$(mktemp /tmp/arcanon-findings-XXXXXX.json)
Then save to SQLite via persistScanResult — applies pending overrides and garbage-collects stale data:
node --input-type=module -e "
import fs from 'fs';
import { openDb } from '${CLAUDE_PLUGIN_ROOT}/worker/db/database.js';
import { QueryEngine } from '${CLAUDE_PLUGIN_ROOT}/worker/db/query-engine.js';
import { persistScanResult } from '${CLAUDE_PLUGIN_ROOT}/worker/scan/scan-service.js';
const db = openDb('${PROJECT_ROOT}');
const qe = new QueryEngine(db);
const findings = JSON.parse(fs.readFileSync('${FINDINGS_FILE}', 'utf8'));
const repoId = qe.upsertRepo({ path: findings.repo_path, name: findings.repo_name, type: 'single' });
const { scanVersionId } = persistScanResult(repoId, findings.repo_path, findings, findings.commit || null, { mode: 'full' }, qe);
console.log('saved');
// surface scan quality at end-of-output. Format string locked in
// CONTEXT D-01 — \"Scan quality: NN% high-confidence, M prose-evidence warnings\".
// prose_evidence_warnings is a 0 placeholder for v0.1.3 (D-01).
const breakdown = qe.getScanQualityBreakdown(scanVersionId);
if (breakdown && breakdown.quality_score !== null) {
const pct = Math.round(breakdown.quality_score * 100);
console.log('Scan quality: ' + pct + '% high-confidence, ' + breakdown.prose_evidence_warnings + ' prose-evidence warnings');
} else if (breakdown) {
console.log('Scan quality: n/a (' + breakdown.total + ' connections)');
}
// write audit rows for connections reclassified by Step 3 reconciliation.
// The \`_reconciliation\` field was attached in Step 3 BEFORE persistFindings so
// it survives the JSON write-then-read round-trip (plain own enumerable property).
// We resolve each reconciled connection's DB id by looking up the persisted
// (source, target, path, method) tuple, then call qe.logEnrichment.
for (const conn of (findings.connections || [])) {
if (!conn._reconciliation) continue;
const sourceRow = db.prepare(
'SELECT id FROM services WHERE name = ? AND repo_id = ?'
).get(conn.source, repoId);
const targetRow = db.prepare(
'SELECT id FROM services WHERE name = ?'
).get(conn.target);
if (!sourceRow || !targetRow) continue;
// \`IS ? OR = ?\` handles SQL's null-vs-string mismatch — NULL is not equal
// to NULL via \`=\`, but \`IS\` handles it. Both bind sites for each column
// receive the same value.
const connRow = db.prepare(
'SELECT id FROM connections WHERE source_service_id = ? AND target_service_id = ? AND ' +
'(path IS ? OR path = ?) AND (method IS ? OR method = ?)'
).get(
sourceRow.id, targetRow.id,
conn.path || null, conn.path || '',
conn.method || null, conn.method || ''
);
if (!connRow) continue;
qe.logEnrichment(
scanVersionId,
'reconciliation',
'connection',
connRow.id,
'crossing',
conn._reconciliation.from,
conn._reconciliation.to,
conn._reconciliation.reason
);
}
"
rm -f "${FINDINGS_FILE}"
Repeat for each repo. Print: "Dependency map saved. N services, M connections."
If this was the first map build, add "impact-map": {"history": true} to arcanon.config.json and print:
Map built successfully. View it with /arcanon:map view
To enable agent-based impact checking, add the Arcanon MCP server to your .mcp.json.
Usage: /arcanon:map [view|full]
Build or refresh the service dependency map by scanning linked repos with Claude agents. Stores findings in SQLite and renders them in the graph UI.
Subcommands:
view — open the existing graph UI without scanningfull — force a full re-scan of all files (asks before deleting prior data)Options:
--help, -h, help — print this help and exitExamples:
/arcanon:map — incremental scan and rebuild graph/arcanon:map view — just open the graph UI (no scanning)/arcanon:map full — force full re-scan of all linked reposWhat the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
15 commands in this plugin
/correctArcanon Correct — Stage Scan OverridesStage a correction to scan findings (insert into scan_overrides). Override is queued, not applied — the next /arcanon:map or /arcanon:rescan run consumes it via the override apply hook. Per invocation, exactly one override row is written./diffArcanon Diff — Scan-Version ComparisonCompare two scan versions. Shows services/connections added, removed, or modified./doctorArcanon Doctor — Diagnostic Suitenpx claudepluginhub arcanon-hub/arcanon --plugin arcanonOther plugins' commands for the same job