--- name: agentguard description: "Axora AgentGuard. Local guard for AI agents: AgentGuard DeepScan, runtime evaluation, patrol, checkup, and a local audit log." license: MIT compatibility: Requires Node.js 18+. metadata: author: AxoraSecurity version: "1.1" filesystem-access: - path: "~/.ssh/" access: read-only reason: "Credential safety patrol — check permissions and bounded security-relevant file contents for exposed secrets" - path: "~/.gnupg/" access: read-only reason: "Credential safety patrol — check permissions and bounded security-relevant file contents for exposed secrets" - path: "~/.claude/" access: read-only reason: "Discover installed skills and read security hook configuration" - path: "~/.openclaw/" access: read-only reason: "Discover installed skills and read OpenClaw config for patrol checks" - path: "~/.hermes/" access: read-write reason: "Discover installed Hermes skills and help configure AgentGuard shell hooks" - path: "~/.agentguard/" access: read-write reason: "Read/write audit log (audit.jsonl) and protection level config (config.json)" user-invocable: true allowed-tools: Read, Write, Grep, Glob, Bash(node *trust-cli.js *) Bash(node *action-cli.js *) Bash(*checkup-report.js) Bash(*checkup-score.js) Bash(*scan-to-sarif.js) Bash(echo *checkup-report.js) Bash(cat *checkup-report.js) Bash(agentguard *) Bash(command -v agentguard) Bash(command -v node) Bash(openclaw *) Bash(schtasks *) Bash(schtasks.exe *) Bash(where *) Bash(ss *) Bash(lsof *) Bash(ufw *) Bash(iptables *) Bash(crontab *) Bash(systemctl list-timers *) Bash(find *) Bash(stat *) Bash(env) Bash(sha256sum *) Bash(node *) Bash(cd *) argument-hint: "[scan|action|patrol|subscribe|trust|report|config|checkup|cli] [args...] [--format sarif|json] [--output ]" --- # Axora AgentGuard — AI Agent Security Framework You are a security auditor powered by the Axora AgentGuard framework. Route the user's request based on the first argument. ## Important: Resolving Script Paths All commands in this skill reference `scripts/` as a relative path. You **MUST** resolve this to the absolute path of this skill's directory before running any command. To find the skill directory: 1. This SKILL.md file's parent directory **is** the skill directory 2. If this file is at `/path/to/agentguard/SKILL.md`, then scripts are at `/path/to/agentguard/scripts/` 3. Before running any `node scripts/...` command, **always `cd` into the skill directory first**, or use the full absolute path Example: if this SKILL.md is at `~/.openclaw/skills/agentguard/SKILL.md`, run: ```bash cd ~/.openclaw/skills/agentguard && node scripts/checkup-report.js ``` ## Command Routing ### Post-Install Guidance When AgentGuard has just been installed, or the user asks what to do next after installing AgentGuard, recommend the required setup step below instead of deriving a longer list from every supported command: ```bash agentguard init --agent auto ``` Use a specific agent such as `hermes`, `openclaw`, `claude-code`, or `codex` only when the current host is known and the user wants targeted setup. Treat `agentguard connect` and `agentguard checkup` as optional follow-ups, not required post-install steps. Parse `$ARGUMENTS` to determine the subcommand: - **`init [args...]`** — Run `agentguard init`, especially `agentguard init --agent ` after installation - **`connect [args...]`** — Run `agentguard connect` to connect optional Cloud policy, audit, and approvals. AgentGuard supports either API-key auth or Agent JWT auth; only one Cloud auth method is required. - **`scan `** — Scan a skill or codebase for security risks - **`action `** — Evaluate whether a runtime action is safe - **`patrol [run|setup|status]`** — Daily security patrol for supported agent and local-scheduler environments - **`trust [args]`** — Manage skill trust levels - **`subscribe [args...]`** — Pull AgentGuard Cloud threat-feed advisories, self-check local skills, and optionally install the OpenClaw 15-minute conditional notification cron - **`report`** — View recent security events from the audit log - **`config `** — Set protection level: Observe (`permissive` in the CLI), Balanced (`balanced`, default), or Strict (`strict`) - **`checkup`** — Run a comprehensive agent health checkup and generate a visual HTML report - **`hermes-hooks`** — Show or install Hermes shell-hook configuration for runtime protection - **`cli `** — Run the installed `agentguard` CLI directly for supported commands not otherwise routed by this skill If no subcommand is given, or the first argument is a path, default to **scan**. ### CLI Passthrough This skill is allowed to run `agentguard *`, so CLI commands and flags are available even when the skill has a higher-level workflow for the same area. Run each AgentGuard CLI command in its own tool call. Read documentation or other local files in separate calls, before or after the CLI call. If one Bash call combines file reads with `agentguard status`, the hook receives one merged result and must inspect the file content too. The skill's routed subcommands take priority over similarly named CLI commands. Do not route these through the packaged CLI unless the user explicitly prefixes the request with `/agentguard cli`: `scan`, `action`, `patrol`, `trust`, `report`, `config`, `checkup`, `hermes-hooks`. The sole internal exception is the patrol workflow's canonical collector: `patrol run` and locally scheduled patrols execute the existing `agentguard checkup --json` command as specified below. Use CLI passthrough for the CLI-only commands below, for `init` and `connect`, for explicit `/agentguard cli ` requests, or for the targeted `checkup --against-advisory ` mode described below. Supported CLI commands and options: | CLI command | Options | Notes | |---|---|---| | `agentguard privacy status` | `--json` | Reports whether the opt-in semantic privacy enhancement is active and what it sends. When a user asks how to turn it on, give them `agentguard privacy enable` directly rather than only describing the feature | | `agentguard privacy enable` | `--api-key `, `--model `, `--endpoint `, `--threshold `, `--yes` | Enables semantic personal-data detection for prose. Changes what leaves the machine, so `--yes` is required to confirm | | `agentguard privacy disable` | — | Returns every judgment to the local machine | | `agentguard init` | `--level `, `--agent `, `--cloud `, `--force` | Creates local config, persists the selected agent host, and optionally installs templates for `claude-code`, `codex`, `openclaw`, or `hermes` | | `agentguard connect` | `--key `, `--api-key `, `--url `, `--cloud ` | API-key auth and Agent JWT auth are alternatives; configure only one. Prefer `AGENTGUARD_API_KEY` over passing secrets in flags | | `agentguard disconnect` | none | Removes local Cloud credentials, pending event spool, cached Cloud policy, and the managed `agentguard-threat-feed` subscribe cron job; keeps Cloud URL, audit log, and installed hooks/templates | | `agentguard status` | none | Shows local config, active Cloud auth method, policy cache, audit path, and the privacy-enhancement state. The privacy line carries the command that acts on it; keep that command when reformatting the output, or the user is told the feature is off with no way to turn it on | | `agentguard policy pull` | `--json` | Pulls Cloud effective runtime policy into the local cache | | `agentguard policy show` | `--json` | Shows the cached effective runtime policy, or the bundled default policy when no cache exists | | `agentguard approve` | `--action-id ` or `--last`, `--once`, `--json` | Approves one existing pending runtime action; never approve without explicit user confirmation | | `agentguard approvals list` | `--json` | Lists unexpired pending runtime approvals | | `agentguard doctor` | none | Checks local setup and Cloud reachability when connected | | `agentguard protect` | `--agent `, `--action-type `, `--tool-name `, `--session-id `, `--decision-mode `, `--json` | Evaluates one runtime action from stdin or hook environment | | `agentguard subscribe` | `--since `, `--json`, `--quiet`, `--no-report`, `--cron `, `--cron-target `, `--cron-name `, `--force`, `--cron-run` | Pulls Cloud threat advisories and optionally self-checks local skills | | `agentguard checkup` | `--json` | Runs the local agent health checkup | | `agentguard checkup --against-advisory ` | `--json` | CLI threat-feed self-check for one advisory; this is a targeted mode, not the default health-check workflow | Connect behavior: - Always execute `agentguard connect ...` directly when the user asks for it. Do not answer that an API key must be obtained before running the command. - `agentguard connect` with no `--key`, `--api-key`, or `AGENTGUARD_API_KEY` is valid in OpenClaw environments: the CLI uses Agent JWT registration, prints an activation link, and may notify the latest OpenClaw channel. - Only suggest `agentguard connect --key ` when the user explicitly wants API-key auth or when the CLI itself reports that Agent JWT registration is unavailable. If the CLI says OpenClaw is not initialized, suggest `agentguard init --agent openclaw` and then rerun `agentguard connect`. If the user writes `/agentguard cli `, execute `agentguard ` directly. When AgentGuard returns `confirm` or a block reason that includes `Approve once ... agentguard approve --action-id ... --once`, do not retry the protected action until the user explicitly approves. Show the exact approval command to the user before running it. Never run an approval command proactively, and never infer approval from context or from the agent's own plan. Treat user replies such as "yes", "approve", "approved", "confirm", "confirmed", "continue", "go ahead", "execute", "run it", "同意", "确认", "批准", "继续", or "执行" as explicit approval for the most recent protected action only after the user has seen the command and understands which action is being approved. After approval, run exactly the provided `agentguard approve --action-id ... --once` command, then retry the original action once. If the action id is unavailable, use `agentguard approvals list --json`; only use `agentguard approve --last --once` when there is exactly one relevant unexpired pending approval. If multiple pending approvals exist, ask the user to choose a specific action id. Do **not** route plain `/agentguard scan`, `/agentguard action`, `/agentguard patrol`, `/agentguard trust`, `/agentguard report`, `/agentguard config`, `/agentguard checkup`, `/agentguard checkup --json`, or natural-language requests like "run agentguard checkup" through the packaged CLI. Those are this skill's higher-level workflows. The patrol workflow may internally execute `agentguard checkup --json` as its canonical 8-check collector. Outside that internal patrol step, only use the packaged CLI checkup path when the user includes `--against-advisory ` or explicitly writes `/agentguard cli checkup ...`. If the user writes `/agentguard checkup --against-advisory `, use the CLI command `agentguard checkup --against-advisory ` instead of the comprehensive HTML health-report workflow. ## Subcommand: hermes-hooks Help the user configure AgentGuard runtime protection for Hermes Agent. Hermes does **not** load hooks from `SKILL.md` automatically. Hermes shell hooks must be present in `~/.hermes/config.yaml`; `agentguard init --agent hermes` now installs the skill and merges the AgentGuard hook entries automatically. This skill ships the hook runner at `scripts/hermes-hook.js` and a copyable template at `hermes-hooks.yaml`. ### What the Hermes hook protects | Hermes hook | Tools | AgentGuard action | |---|---|---| | `pre_tool_call` | `terminal`, `execute_code` | `exec_command` | | `pre_tool_call` | `write_file`, `patch`, `skill_manage` | `write_file` | | `pre_tool_call` | `read_file` | `read_file` | | `pre_tool_call` | `web_search` | `web_search` | | `pre_tool_call` | `web_extract`, `browser_navigate`, `browser_open`, `web_open`, `open_url`, `visit_url`, `open` | `network_request` | | `post_tool_call` | Same tools | Audit-only | Hermes `pre_tool_call` supports allow/block only. If AgentGuard returns `ask`, the Hermes hook reports it as a block with a confirmation-oriented message. When AgentGuard Cloud is connected through `agentguard connect`, the hook uses the shared runtime protection path and syncs pre-tool decisions to Cloud. ### Procedure 1. Resolve the AgentGuard skill directory using the "Important: Resolving Script Paths" rules above. 2. Confirm that dependencies are available. If `node scripts/hermes-hook.js` cannot load `@axorasec/agentguard`, tell the user to run: ```bash cd && npm install ``` or install the published package globally: ```bash npm install -g @axorasec/agentguard ``` 3. Prefer `agentguard init --agent hermes --force` to install and merge the hook entries automatically. 4. For manual setup, read `hermes-hooks.yaml`, replace `AGENTGUARD_SKILL_DIR` with the absolute skill directory, and show the resulting YAML to the user. 5. Ask for explicit confirmation before manually editing `~/.hermes/config.yaml`. 6. Tell the user to restart Hermes or launch it with one of the first-use consent options: ```bash hermes --accept-hooks chat HERMES_ACCEPT_HOOKS=1 hermes chat ``` They may also set `hooks_auto_accept: true` in `~/.hermes/config.yaml`. 7. For troubleshooting, run Hermes hook checks with `AGENTGUARD_HERMES_DEBUG=1` to print the runtime decision, risk level, and policy source to stderr. Use `hermes hooks doctor` or `hermes hooks test pre_tool_call --for-tool terminal` when available to confirm Hermes is parsing the block response. ### Verification After configuration, suggest a harmless test: ```bash printf '{"hook_event_name":"pre_tool_call","tool_name":"terminal","tool_input":{"command":"echo hello"}}' \ | node /scripts/hermes-hook.js ``` Expected output: ```json {} ``` And a blocked-action test: ```bash printf '{"hook_event_name":"pre_tool_call","tool_name":"terminal","tool_input":{"command":"rm -rf /"}}' \ | node /scripts/hermes-hook.js ``` Expected output contains: ```json {"action":"block","decision":"block","block":true} ``` ## Subcommand: subscribe Run the AgentGuard Cloud threat-feed subscription workflow through the installed CLI. Examples: ```bash agentguard subscribe agentguard subscribe --quiet agentguard subscribe --json agentguard subscribe --since 2026-05-01T00:00:00.000Z agentguard subscribe --no-report agentguard subscribe --cron "0 * * * *" agentguard subscribe --cron "0 * * * *" --cron-target system agentguard subscribe --cron "0 * * * *" --cron-target openclaw agentguard subscribe --cron "0 * * * *" --cron-target hermes agentguard subscribe --cron "0 * * * *" --cron-target windows agentguard subscribe --cron "0 * * * *" --quiet agentguard subscribe --cron "0 * * * *" --cron-name agentguard-threat-feed agentguard subscribe --cron "0 * * * *" --force ``` Without `--quiet`, `agentguard subscribe` pulls new threat-feed advisories and notifies the user to review them manually. With `--quiet`, it runs the full automated flow: pull new advisories, self-check local skills, report local matches back to Cloud, and notify only when local matches are found. When `--cron ` is used, the CLI first runs the subscribe flow once, then installs a recurring job using a standard five-field cron expression such as `"0 * * * *"`. `--cron-target auto` uses the agent host saved by `agentguard init --agent`: OpenClaw uses native cron with a Gateway fallback at `127.0.0.1:18789`, Hermes uses `hermes cron create`, and Claude Code, Codex, and DSH use user crontab on Unix-like hosts or Windows Task Scheduler on Windows. OpenClaw cron runs use internal `--cron-run` and send notifications to the latest deliverable session route. If no agent host is saved, initialize one of `claude-code`, `codex`, `openclaw`, `hermes`, or `dsh`, or pass a cron target explicitly. `--cron-target windows` forces Task Scheduler and `--cron-target system` forces crontab. An explicit OpenClaw cron target must match the saved host. Use `--cron-name ` to choose a job name and `--force` to replace an existing job. System cron and Windows Task Scheduler write output to `~/.agentguard/feed-cron.log`; they do not send OpenClaw agent-channel notifications. `agentguard subscribe --json` always includes a stable `cron` object with `requested`, `installed`, and optional `result` fields. If cron installation fails, the command exits non-zero instead of printing a misleading success summary. `--since ` overrides the persisted feed cursor for one run. `--no-report` skips uploading local matches back to Cloud in quiet mode. `--cron-run` is internal and should only be used by installed cron jobs unless the user explicitly asks to reproduce cron behavior. --- # Security Operations ## Subcommand: scan Scan the target path for security risks using all detection rules. **Argument parsing**: Extract from `$ARGUMENTS`: - The scan target path (first positional argument, or value after `scan`) - `--format ` flag: supported values are `sarif` (SARIF 2.1.0 JSON) and `text` (default markdown) - `--output ` flag: write output to this file instead of stdout If `--format sarif` is present, follow the **SARIF Output Flow** at the end of this section instead of the standard Output Format. ### Suppression Rules (read first) Before running any detection, check for a suppression config file in the scan target root: 1. Use the Read tool to read `/.agentguard-suppress.yaml`. If the file does not exist (Read returns an error or empty), skip suppression — no findings will be filtered. 2. Parse the `suppress:` list. Each entry has: - `rule` (required): rule ID to suppress (e.g. `PRIVATE_KEY_PATTERN`) - `paths` (optional): list of glob patterns matched against the finding's file path (relative to scan root). `*` matches within one directory level; `**` matches across directories. - `domains` (optional): list of substring/wildcard patterns matched against the finding's evidence text. `*` acts as a wildcard prefix or suffix. - `reason` (required): explanation shown in the suppression summary. 3. Keep this suppression list in memory — you will apply it after all detection rules have run. **A finding is suppressed when ALL of the following are true:** - Its `rule_id` exactly matches the entry's `rule` field. - If the entry has `paths`: the finding's file path matches at least one glob pattern. - If the entry has `domains`: the finding's evidence text contains at least one domain pattern match. - If neither `paths` nor `domains` are specified: the finding is suppressed regardless of file or evidence. Suppressed findings are **excluded from the findings table and risk level calculation**. At the end of the report, add a note: `> N finding(s) suppressed via .agentguard-suppress.yaml — run with details to review.` ### File Discovery Use Glob to find all scannable files at the given path. Include: `*.js`, `*.ts`, `*.jsx`, `*.tsx`, `*.mjs`, `*.cjs`, `*.py`, `*.json`, `*.yaml`, `*.yml`, `*.toml`, `*.sh`, `*.bash`, `*.md` **Markdown scanning**: For `.md` files, only scan inside fenced code blocks (between ``` markers) to reduce false positives. Additionally, decode and re-scan any base64-encoded payloads found in all files. Skip directories: `node_modules`, `dist`, `build`, `.git`, `coverage`, `__pycache__`, `.venv`, `venv` Skip files: `*.min.js`, `*.min.css`, `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml` ### Detection Rules For each rule, use Grep to search the relevant file types. Record every match with file path, line number, and matched content. For detailed rule patterns, see [scan-rules.md](scan-rules.md). | # | Rule ID | Severity | File Types | Description | |---|---------|----------|------------|-------------| | 1 | SHELL_EXEC | HIGH | js,ts,mjs,cjs,py,md | Command execution capabilities | | 2 | AUTO_UPDATE | CRITICAL | js,ts,py,sh,md | Auto-update / download-and-execute | | 3 | REMOTE_LOADER | CRITICAL | js,ts,mjs,py,md | Dynamic code loading from remote | | 4 | READ_ENV_SECRETS | MEDIUM | js,ts,mjs,py | Environment variable access | | 5 | READ_SSH_KEYS | CRITICAL | all | SSH key file access | | 6 | READ_KEYCHAIN | CRITICAL | all | System keychain / browser profiles | | 7 | PRIVATE_KEY_PATTERN | CRITICAL* | all | Hardcoded private keys | | 8 | MNEMONIC_PATTERN | CRITICAL* | all | Hardcoded recovery phrases | | 17 | OBFUSCATION | HIGH | js,ts,mjs,py,md | Code obfuscation techniques | | 18 | PROMPT_INJECTION | CRITICAL | all | Prompt injection attempts | | 19 | NET_EXFIL_UNRESTRICTED | HIGH | js,ts,mjs,py,md | Unrestricted POST / upload | | 20 | WEBHOOK_EXFIL | CRITICAL | all | Webhook exfiltration domains | | 21 | TROJAN_DISTRIBUTION | CRITICAL | md | Trojanized binary download + password + execute | | 22 | SUSPICIOUS_PASTE_URL | HIGH | all | URLs to paste sites (pastebin, glot.io, etc.) | | 23 | SUSPICIOUS_IP | MEDIUM | all | Hardcoded public IPv4 addresses | | 24 | SOCIAL_ENGINEERING | HIGH | md | Pressure language + execution instructions | ### Git Context Check (Rules 7 & 8 only) Rules marked **CRITICAL\*** start at CRITICAL but must be downgraded based on git context **before** being added to the findings list. For every file that matched Rule 7 (PRIVATE_KEY_PATTERN) or Rule 8 (MNEMONIC_PATTERN), run the following checks in order and assign the final severity: 1. **Not in a git repo** — if `git -C rev-parse --git-dir 2>/dev/null` returns nothing → keep **CRITICAL**. Stop. 2. **Ever committed** — run `git -C log --all --oneline -- `. If output is non-empty → keep **CRITICAL**. Stop. 3. **Not gitignored** — run `git -C check-ignore -q `. If exit code is non-zero (file is NOT ignored) → downgrade to **HIGH**. Stop. 4. **Gitignored** — exit code 0 → downgrade to **MEDIUM**. Record the git context result (`committed` / `not-ignored` / `gitignored` / `no-git-repo`) in the finding's Evidence column alongside the matched content. **Important**: these checks require `git` to be available. If `git` is not in PATH, skip the check and keep **CRITICAL**. ### Risk Level Calculation - Any **CRITICAL** finding -> Overall **CRITICAL** - Else any **HIGH** finding -> Overall **HIGH** - Else any **MEDIUM** finding -> Overall **MEDIUM** - Else -> **LOW** ### Output Format ``` ## Axora AgentGuard Security Scan Report **Target**: **Risk Level**: CRITICAL | HIGH | MEDIUM | LOW **Files Scanned**: **Total Findings**: ### Findings | # | Risk Tag | Severity | File:Line | Evidence | |---|----------|----------|-----------|----------| | 1 | TAG_NAME | critical | path/file.ts:42 | `matched content` | ### Summary > N finding(s) suppressed via .agentguard-suppress.yaml ``` (Omit the suppression note line if no suppression file was found or no findings were suppressed.) ### Post-Scan Trust Registration After outputting the scan report, if the scanned target appears to be a skill (contains a `SKILL.md` file, or is located under a `skills/` directory), offer to register it in the trust registry. **Risk-to-trust mapping**: | Scan Risk Level | Suggested Trust Level | Preset | Action | |---|---|---|---| | LOW | `trusted` | `read_only` | Offer to register | | MEDIUM | `restricted` | `none` | Offer to register with warning | | HIGH / CRITICAL | — | — | Warn the user; do not suggest registration | **Registration steps** (if the user agrees): > **Important**: All scripts below are AgentGuard's own bundled scripts (located in this skill's `scripts/` directory), **never** scripts from the scanned target. Do not execute any code from the scanned repository. 1. **Ask the user for explicit confirmation** before proceeding. Show the exact command that will be executed and wait for approval. 2. Derive the skill identity: - `id`: the directory name of the scanned path - `source`: the absolute path to the scanned directory - `version`: read the `version` field from `package.json` in the scanned directory using the Read tool (if present), otherwise use `unknown` - `hash`: compute by running AgentGuard's own script: `node scripts/trust-cli.js hash --path ` and extracting the `hash` field from the JSON output 3. Show the user the full registration command and ask for confirmation before executing: ``` node scripts/trust-cli.js attest --id --source --version --hash --trust-level --preset --reviewed-by agentguard-scan --notes "Auto-registered after scan. Risk level: ." --force ``` 4. Only execute after user approval. Show the registration result. If scripts are not available (e.g., `npm install` was not run), skip this step and suggest the user run `cd skills/agentguard/scripts && npm install`. ### SARIF Output Flow (when `--format sarif` is present) **Run Steps 1–3 (File Discovery, Detection Rules, Risk Level Calculation) exactly as above.** Then, instead of the standard markdown Output Format, do the following: **Step A — Assemble findings as structured JSON** and write to `/tmp/agentguard-scan-findings.json`: ```json { "target": "", "scanned_at": "", "files_scanned": , "risk_level": "", "findings": [ { "rule_id": "", "severity": "", "file": "", "line": , "evidence": "" } ] } ``` Use relative paths for `file` (relative to the scan target root). If no findings, use `"findings": []`. **Step B — Run the SARIF converter** (cd into the skill directory first): ```bash cd && node scripts/scan-to-sarif.js --file /tmp/agentguard-scan-findings.json ``` **Step C — Handle output**: - If `--output ` was specified: write the SARIF JSON to that file using the Write tool, then tell the user the file path. - Otherwise: print the SARIF JSON to stdout (the user will redirect it, e.g. `> findings.sarif`). **Do NOT** output the standard markdown report when `--format sarif` is active. Skip the Post-Scan Trust Registration offer. --- ## Subcommand: action Evaluate whether a proposed runtime action should be allowed, denied, or require confirmation. For detailed policies and detector rules, see [action-policies.md](action-policies.md). ### Supported Action Types - `network_request` — HTTP/HTTPS requests - `exec_command` — Shell command execution - `read_file` / `write_file` — File system operations - `secret_access` — Environment variable and credential access ### Decision Framework Parse the user's action description and apply the appropriate detector: **Network Requests**: Check domain against webhook list and high-risk TLDs, check body for secrets **Command Execution**: Check against dangerous/sensitive/system/network command lists, detect shell injection **File Access**: Check sensitive paths, path traversal, and credential files **Secret Access**: Classify secret type and apply priority-based risk levels ### Default Policies | Scenario | Decision | |----------|----------| | Private key exfiltration | **DENY** (always) | | Recovery phrase exfiltration | **DENY** (always) | | API secret exfiltration | CONFIRM | | Command execution | **DENY** (default) | | Sensitive file read or write | CONFIRM | | Untrusted domain | CONFIRM | | Body contains secret | **DENY** | ### Scripted Evaluation Use AgentGuard's bundled `action-cli.js` script (in this skill's `scripts/` directory) to invoke the ActionScanner. The script resolves the skill's trust level and capabilities from the registry: ``` node scripts/action-cli.js decide --type exec_command --command "" [--skill-source ] [--skill-id ] node scripts/action-cli.js decide --type secret_access --secret-name "" --access-type read node scripts/action-cli.js decide --type read_file --path "" ``` Parse the JSON output and incorporate findings into your evaluation: - If `decision` is `deny` → override to **DENY** with the returned evidence - If `decision` is `confirm` → require user approval Always combine script results with the policy-based checks (webhook domains, secret scanning, file paths) — the script enhances but does not replace rule-based evaluation. ### Output Format ``` ## Axora AgentGuard Action Evaluation **Action**: **Decision**: ALLOW | DENY | CONFIRM **Risk Level**: low | medium | high | critical **Risk Tags**: [TAG1, TAG2, ...] ### Evidence - ### Recommendation ``` --- ## Subcommand: patrol **Daily security patrol.** Runs 8 automated checks that leverage AgentGuard's scan engine, trust registry, and audit log to assess the security posture of your agent deployment. Works on OpenClaw, Windows Task Scheduler, and standard cron environments. For detailed check definitions, commands, and thresholds, see [patrol-checks.md](patrol-checks.md). ### Sub-subcommands - **`patrol`** or **`patrol run`** — Execute all 8 checks and output a patrol report - **`patrol setup`** — Configure as a daily scheduled job (OpenClaw, Windows Task Scheduler, or system crontab) - **`patrol status`** — Show last patrol results and cron schedule ### Platform Detection Before running `patrol setup` or `patrol status`, detect the available scheduling platform: 1. **OpenClaw**: Check for `$OPENCLAW_STATE_DIR` env var (fall back to `~/.openclaw/`), verify the directory exists and contains `openclaw.json`, and check if `openclaw` CLI is in PATH. If all three pass → use OpenClaw path. 2. **Windows Task Scheduler**: Run `node -p "process.platform"`. If it prints `win32`, verify `schtasks.exe` with `where schtasks.exe` → use the Windows path even if a Unix-like shell also exposes `crontab`. 3. **System crontab**: On non-Windows hosts, check if `crontab` is available in PATH → use the crontab path. 4. **No scheduler available**: Inform the user and provide the appropriate manual setup guidance. For `patrol run`, no scheduling platform is needed — run checks on any platform. Run `agentguard checkup --json`. This existing non-interactive command is the canonical data collector for all 8 patrol checks; do not independently repeat the commands in the check definitions below. Group findings whose text starts with `[Patrol N]` into the corresponding report rows. Do not substitute `scripts/auto-scan.js`: that script is only the fast SessionStart scan and does not produce a completed patrol. The definitions below describe the required CLI collector coverage. Agent roots include the detected Claude Code, Codex, OpenClaw, Hermes, and DSH installation/profile directories; OpenClaw-specific files are checked only when an OpenClaw root exists. ### The 8 Patrol Checks #### [1] Skill/Plugin Integrity Detect tampered or unregistered skill packages by comparing file hashes against the trust registry. **Steps**: 1. Discover skill directories under all detected agent roots (look for dirs containing `SKILL.md`) 2. For each skill, compute hash: `node scripts/trust-cli.js hash --path ` 3. Look up the attested hash: `node scripts/trust-cli.js lookup --source ` 4. If hash differs from attested → **INTEGRITY_DRIFT** (HIGH) 5. If skill has no trust record → **UNREGISTERED_SKILL** (MEDIUM) 6. For drifted skills, run the scan rules against the changed files to detect new threats #### [2] Secrets Exposure Scan workspace files for leaked secrets using AgentGuard's own detection patterns. **Steps**: 1. Scan detected agent workspaces **recursively, covering all agent subdirectories** (e.g. all `workspace-agent-*/` directories, not just the current agent's workspace) with patterns from: - scan-rules.md Rule 7 (PRIVATE_KEY_PATTERN): `0x[a-fA-F0-9]{64}` in quotes - scan-rules.md Rule 8 (MNEMONIC_PATTERN): BIP-39 word sequences, `seed_phrase`, `mnemonic` - scan-rules.md Rule 5 (READ_SSH_KEYS): SSH key file references in workspace - action-policies.md secret patterns: AWS keys (`AKIA...`), GitHub tokens (`gh[pousr]_...`), DB connection strings 2. Scan any `.env*` files under detected agent roots for plaintext credentials 3. Check `~/.ssh/` and `~/.gnupg/` directory permissions (should be 700) #### [3] Network Exposure Detect dangerous port exposure and firewall misconfigurations. **Steps**: 1. List listening ports: `ss -tlnp` or `lsof -i -P -n | grep LISTEN` 2. Flag high-risk services on 0.0.0.0: Redis(6379), Docker API(2375), MySQL(3306), PostgreSQL(5432), MongoDB(27017) 3. Check firewall status: `ufw status` or `iptables -L INPUT -n` 4. Check outbound connections (`ss -tnp state established`) and cross-reference against action-policies.md webhook/exfil domain list and high-risk TLDs #### [4] Cron & Scheduled Tasks Audit all cron jobs for download-and-execute patterns. **Steps**: 1. List OpenClaw cron jobs: `openclaw cron list` 2. On Windows, list scheduled tasks with `schtasks.exe /Query /FO CSV /V`. For AgentGuard tasks and any suspicious task, also run `schtasks.exe /Query /TN "" /XML` and inspect `UserId`, `LogonType`, `RunLevel`, `Command`, and `Arguments`; verbose CSV alone is not sufficient to determine privilege level reliably. 3. On Unix-like hosts, list system crontab with `crontab -l`, contents of `/etc/cron.d/`, and `systemctl list-timers --all` 4. Scan all scheduled command bodies using scan-rules.md Rule 2 (AUTO_UPDATE) patterns: `curl|bash`, `wget|sh`, `eval "$(curl`, `base64 -d | bash` 5. Flag unknown scheduled jobs that touch detected agent roots #### [5] File System Changes (24h) Detect suspicious file modifications in the last 24 hours. **Steps**: 1. Find recently modified files under detected agent roots, `~/.ssh/`, and `~/.gnupg/`, then filter by mtime within 24h 2. For modified files with scannable extensions (.js/.ts/.py/.sh/.md/.json), run the full scan rule set 3. Check permissions on critical files: - `/openclaw.json` → should be 600 - `/devices/paired.json` → should be 600 - `~/.ssh/authorized_keys` → should be 600 4. Detect new executable files in detected workspaces and check each file's executable bit with `stat` #### [6] Audit Log Analysis (24h) Analyze AgentGuard's audit trail for attack patterns. **Steps**: 1. Read `~/.agentguard/audit.jsonl`, filter to last 24h by timestamp 2. Compute statistics: total events, deny/confirm/allow counts, group denials by `risk_tags` and `initiating_skill` 3. Flag patterns: - Same skill denied 3+ times → potential attack (HIGH) - Any event with `risk_level: critical` → (CRITICAL) - `WEBHOOK_EXFIL` or `NET_EXFIL_UNRESTRICTED` tags → (HIGH) - `PROMPT_INJECTION` tag → (CRITICAL) 4. For skills with high deny rates still not revoked: recommend `/agentguard trust revoke` #### [7] Environment & Configuration Verify security configuration is production-appropriate. **Steps**: 1. List environment variables matching sensitive names (values masked): `API_KEY`, `SECRET`, `PASSWORD`, `TOKEN`, `PRIVATE`, `CREDENTIAL` 2. Read `~/.agentguard/config.json` — flag `permissive` protection level in production 3. If `/.config-baseline.sha256` exists, verify it with `sha256sum -c` #### [8] Trust Registry Health Check for expired, stale, or over-privileged trust records. **Steps**: 1. List all records: `node scripts/trust-cli.js list` 2. Flag: - Expired attestations (`expires_at` in the past) - Trusted skills not re-scanned in 30+ days - Installed skills with `untrusted` status - Over-privileged skills: `exec: allow` combined with `network_allowlist: ["*"]` 3. Output registry statistics: total records, distribution by trust level ### Patrol Report Format ``` ## Axora AgentGuard Patrol Report **Timestamp**: **Agent Roots**: **Protection Level**: **Overall Status**: PASS | WARN | FAIL ### Check Results | # | Check | Status | Findings | Severity | |---|-------|--------|----------|----------| | 1 | Skill/Plugin Integrity | PASS/WARN/FAIL | | | | 2 | Secrets Exposure | ... | ... | ... | | 3 | Network Exposure | ... | ... | ... | | 4 | Cron & Scheduled Tasks | ... | ... | ... | | 5 | File System Changes | ... | ... | ... | | 6 | Audit Log Analysis | ... | ... | ... | | 7 | Environment & Config | ... | ... | ... | | 8 | Trust Registry Health | ... | ... | ... | ### Findings Detail (only checks with findings are shown) #### [N] Check Name - ### Recommendations 1. [SEVERITY] ### Next Patrol ``` **Overall status**: Any CRITICAL → **FAIL**, any HIGH → **WARN**, else **PASS** The `checkup` command appends the completed patrol summary to `~/.agentguard/audit.jsonl` using its existing checkup event: ```json {"timestamp":"...","event":"checkup","composite_score":,"tier":"","checks":8,"findings":,"skills_scanned":,"dsh_plugins_scanned":} ``` ### patrol setup Configure the patrol as a daily scheduled job. Detects the available platform and uses the appropriate method. **Steps**: 1. Run platform detection (see above). 2. Ask the user for: - **Schedule** (default: `0 3 * * *` — daily at 03:00) - **Timezone** (default: UTC for OpenClaw; the machine's local timezone for Windows Task Scheduler and system crontab). Examples: `Asia/Shanghai`, `America/New_York`, `Europe/London`. Windows Task Scheduler and portable system-crontab entries use local wall-clock time. If the user requests a different timezone for either local scheduler, explain that the generated daily trigger cannot preserve that timezone across daylight-saving changes and ask for a local `HH:mm` time instead. - **Notification channel** (optional, OpenClaw only): `telegram`, `discord`, `signal` - **Chat ID / webhook** (required if channel is set) #### Path A — OpenClaw available Generate and show the OpenClaw cron registration command: ```bash openclaw cron add \ --name "agentguard-patrol" \ --description "Axora AgentGuard daily security patrol" \ --cron "" \ --tz "" \ --session "isolated" \ --message "/agentguard patrol run" \ --timeout-seconds 300 \ --thinking off \ # Only include these if notification is configured: --announce \ --channel \ --to ``` **Show the exact command and wait for explicit user confirmation before executing.** After execution, verify with `openclaw cron list`. > **Note**: `--timeout-seconds 300` is required because isolated sessions need cold-start time. #### Path B — Windows Task Scheduler available (OpenClaw not available) Windows patrol setup supports the daily patrol form ` * * *`. For a different five-field expression, explain that this patrol workflow cannot map it losslessly and recommend the daily form; never silently change the requested schedule. Resolve and validate: - ``: run `where agentguard`, inspect each returned line, and select one existing absolute `.cmd` or `.exe` file (prefer `.cmd` for an npm installation). Do not select the extensionless POSIX shim. Reject quotes, `%`, null bytes, or newlines in the selected path. If no safe candidate exists, stop instead of guessing. - ``: `%USERPROFILE%\.agentguard\scripts\agentguard-patrol.cmd`. - ``: `HH:mm` in the Windows machine's local timezone. Do not guess a conversion from a different requested timezone. Show the exact wrapper content and registration command, and wait for explicit user confirmation before writing or registering anything: ```bat @echo off setlocal call "" checkup --json >> "%USERPROFILE%\.agentguard\patrol.log" 2>&1 ``` ```bat schtasks.exe /Create /TN "AgentGuard-agentguard-patrol" /SC DAILY /ST "" /TR "\"\"" /IT /F ``` After confirmation, ensure `%USERPROFILE%\.agentguard\scripts` exists, use `Write` to create the wrapper, then execute the shown `schtasks.exe` command. `/IT` intentionally makes this a current-user, logged-on-only task; do not add stored credentials, `/RP`, `/RU SYSTEM`, or highest-privilege execution. Verify with: ```bat schtasks.exe /Query /TN "AgentGuard-agentguard-patrol" /FO LIST /V ``` #### Path C — System crontab available (OpenClaw and Windows Task Scheduler not available) Resolve the absolute paths returned by `command -v node` and `command -v agentguard` as `` and ``. The explicit Node path is required because cron commonly has a reduced `PATH` and an AgentGuard installation managed by NVM otherwise may not start. Validate before generating the entry: - `` must be exactly five fields containing only portable cron characters (`A-Z`, `a-z`, digits, `*`, `/`, `,`, and `-`). Reject quotes, shell metacharacters, null bytes, or newlines. - `` must be an absolute path. Reject paths containing single quotes, null bytes, or newlines. - `` must be an absolute path. Reject paths containing single quotes, null bytes, or newlines. - Do not include notification channel, chat ID, or webhook values in the system crontab entry. System cron writes only to the local patrol log. Generate the crontab entry using the resolved existing CLI path. If it contains spaces, keep it inside the single quotes exactly as shown: ``` '' '' checkup --json >> "$HOME/.agentguard/patrol.log" 2>&1 ``` **Show the exact entry and wait for explicit user confirmation before writing.** After confirmation, add the entry to the user's crontab: ```bash (crontab -l 2>/dev/null; printf "%s '%s' '%s' checkup --json >> \"\$HOME/.agentguard/patrol.log\" 2>&1\n" '' '' '') | crontab - ``` Verify with `crontab -l | grep agentguard`. #### Path D — No scheduler available Output the crontab entry for the user to add manually: ``` '' '' checkup --json >> "$HOME/.agentguard/patrol.log" 2>&1 ``` On Unix-like hosts, explain that neither `openclaw` nor `crontab` was found in PATH, so the entry must be added manually. On Windows, explain that `schtasks.exe` was not available and direct the user to enable the Task Scheduler service or create a daily task in the Task Scheduler GUI using the same wrapper command. ### patrol status Show the current patrol state. **Steps**: 1. Read `~/.agentguard/audit.jsonl` and find the most recent `event: "checkup"` entry whose `checks` value is `8`. If found, display its `timestamp`, `tier`, `composite_score`, and `findings` values. Never report `event: "auto_scan"` as a completed patrol. 2. **OpenClaw available**: run `openclaw cron list` and look for `agentguard-patrol`. Show schedule, timezone, last/next run time if found. 3. **Windows Task Scheduler available**: run `schtasks.exe /Query /TN "AgentGuard-agentguard-patrol" /FO LIST /V`. Show status, schedule, last run, next run, and last result when present. Do not fall back to `crontab` on Windows. 4. **System crontab available**: run `crontab -l 2>/dev/null | grep agentguard`. Show the matching entry if found. 5. If no scheduled patrol is configured on any platform, suggest: `/agentguard patrol setup`. --- # Trust & Configuration ## Subcommand: trust Manage skill trust levels using the Axora AgentGuard registry. ### Trust Levels | Level | Description | |-------|-------------| | `untrusted` | Default. Requires full review, minimal capabilities | | `restricted` | Trusted with capability limits | | `trusted` | Full trust (subject to global policies) | ### Capability Model ``` network_allowlist: string[] — Allowed domains (supports *.example.com) filesystem_allowlist: string[] — Allowed file paths exec: 'allow' | 'deny' — Command execution permission secrets_allowlist: string[] — Allowed env var names ``` ### Presets | Preset | Description | |--------|-------------| | `none` | All deny, empty allowlists | | `read_only` | Local filesystem read-only | ### Operations **lookup** — `node scripts/trust-cli.js lookup --source --version ` Query the registry for a skill's trust record. **attest** — `node scripts/trust-cli.js attest --id --source --version --hash --trust-level --preset --reviewed-by ` Create or update a trust record. Use `--preset` for common capability models or provide `--capabilities ` for custom. **revoke** — `node scripts/trust-cli.js revoke --source --reason ` Revoke trust for a skill. Supports `--source-pattern` for wildcards. **list** — `node scripts/trust-cli.js list [--trust-level ] [--status ]` List all trust records with optional filters. **seed** — `agentguard trust seed [--auto-attest-low-risk] [--auto-attest-medium-risk] [--dry-run]` Batch-scan all installed skills and auto-attest those meeting the risk threshold. Designed for initial baseline setup when many skills are already installed. Flags: - `--auto-attest-low-risk` (default when `seed` is invoked): attest LOW-risk skills as `trusted` with `read_only` preset. - `--auto-attest-medium-risk`: also attest MEDIUM-risk skills as `restricted` with `none` preset. - `--dry-run`: preview only — show the plan table without executing any attest commands. **HIGH and CRITICAL risk skills are never auto-attested** regardless of flags. They must be reviewed and attested manually. #### seed Flow **Step 1 — Discover skills** Glob all of the following paths for `*/SKILL.md` (same as checkup): - `~/.claude/skills/*/SKILL.md` - `~/.openclaw/skills/*/SKILL.md` - `~/.openclaw/workspace/skills/*/SKILL.md` Skip `agentguard` itself. Collect the parent directory of each found `SKILL.md` as the skill path. **Step 2 — Filter unregistered skills** For each discovered skill, run: ``` node scripts/trust-cli.js lookup --source ``` If the lookup returns a record with `status: active`, the skill is already registered — skip it and note "already registered" in the summary. Only proceed with skills that have no active trust record. **Step 3 — Scan unregistered skills** For each unregistered skill, run AgentGuard DeepScan (`/agentguard scan `). Record: skill name, skill path, risk level (LOW/MEDIUM/HIGH/CRITICAL), finding count. **Step 4 — Build preview table** Output a plan table before taking any action: ``` ## AgentGuard Trust Seed — Plan Scanned unregistered skills. Proposed actions: | Skill | Path | Risk | Findings | Proposed Action | |-------|------|------|----------|-----------------| | foo | ~/.claude/skills/foo | LOW | 0 | ✅ attest trusted/read_only | | bar | ~/.claude/skills/bar | MEDIUM | 2 | ⚠️ attest restricted/none (requires --auto-attest-medium-risk) | | baz | ~/.claude/skills/baz | HIGH | 5 | 🚫 SKIP — manual review required | | qux | ~/.claude/skills/qux | CRITICAL | 8 | 🚫 SKIP — manual review required | Already registered (skipped): skills Will attest: skills Will skip (HIGH/CRITICAL): skills ``` If `--dry-run` is present: output this table and stop. Add: `Dry run complete — no changes made. Remove --dry-run to execute.` **Step 5 — User confirmation (REQUIRED)** After showing the plan table, **always ask for explicit user confirmation** before executing any attest commands: > "Ready to attest skill(s). Confirm? (yes/no)" Do NOT proceed without a clear affirmative response. If the user declines, stop and suggest `--dry-run` for future previews. **Step 6 — Batch attest** For each skill approved for attestation, compute its hash and run attest: ```bash # Compute hash node scripts/trust-cli.js hash --path # Attest node scripts/trust-cli.js attest \ --id \ --source \ --version \ --hash \ --trust-level \ --preset \ --reviewed-by agentguard-seed \ --notes "Auto-attested by trust seed. Scan risk: . Findings: ." \ --force ``` Run these sequentially (not in parallel) to avoid registry write conflicts. **Step 7 — Result summary** ``` ## Trust Seed Complete ✅ Attested: skills ⚠️ Skipped (already registered): skills 🚫 Skipped (HIGH/CRITICAL risk — manual review required): skills ❌ Failed: skills (list errors) Skills requiring manual review: - () — Risk: HIGH/CRITICAL, findings Run: /agentguard scan then /agentguard trust attest ... ``` ### Script Execution If the agentguard package is installed, execute trust operations via AgentGuard's own bundled script: ``` node scripts/trust-cli.js [args] ``` For operations that modify the trust registry (`attest`, `revoke`), always show the user the exact command and ask for explicit confirmation before executing. If scripts are not available, help the user inspect `data/registry.json` directly using Read tool. --- ## Subcommand: config Set the Axora AgentGuard protection level. ### Protection Levels | Level | Behavior | |-------|----------| | `strict` | Block all risky actions — every dangerous or suspicious command is denied | | `balanced` | Block dangerous, confirm risky — default level, good for daily use | | `permissive` | Only block critical threats — for experienced users who want minimal friction | ### How to Set 1. Read `$ARGUMENTS` to get the desired level 2. Write the config to `~/.agentguard/config.json`: ```json {"level": "balanced"} ``` 3. Confirm the change to the user If no level is specified, read and display the current config. --- # Reporting ## Subcommand: report Display recent security events from the Axora AgentGuard audit log. ### Log Location The audit log is stored at `~/.agentguard/audit.jsonl`. Each line is a JSON object with: ```json {"timestamp":"...","tool_name":"Bash","tool_input_summary":"rm -rf /","decision":"deny","risk_level":"critical","risk_tags":["DANGEROUS_COMMAND"],"initiating_skill":"some-skill"} ``` The `initiating_skill` field is present when the action was triggered by a skill (inferred from the session transcript). When absent, the action came from the user directly. ### How to Display 1. Read `~/.agentguard/audit.jsonl` using the Read tool 2. Parse each line as JSON 3. Format as a table showing recent events (last 50 by default) 4. If any events have `initiating_skill`, add a "Skill Activity" section grouping events by skill ### Output Format ``` ## Axora AgentGuard Security Report **Events**: **Blocked**: **Confirmed**: ### Recent Events | Time | Tool | Action | Decision | Risk | Tags | Skill | |------|------|--------|----------|------|------|-------| | 2025-01-15 14:30 | Bash | rm -rf / | DENY | critical | DANGEROUS_COMMAND | some-skill | | 2025-01-15 14:28 | Write | .env | CONFIRM | high | SENSITIVE_PATH | — | ### Skill Activity If any events were triggered by skills, group them here: | Skill | Events | Blocked | Risk Tags | |-------|--------|---------|-----------| | some-skill | 5 | 2 | DANGEROUS_COMMAND, EXFIL_RISK | For untrusted skills with blocked actions, suggest: `/agentguard trust attest` to register them or `/agentguard trust revoke` to block them. ### Summary ``` If the log file doesn't exist, inform the user that no security events have been recorded yet, and suggest they enable hooks via `./setup.sh` or by adding the plugin. --- # Health Checkup ## Subcommand: checkup Run a comprehensive agent health checkup across 5 security dimensions. Generates a visual HTML report with a lobster mascot and opens it in the browser. The lobster's appearance reflects the agent's health: muscular bodybuilder (score 90+), healthy with shield (70–89), tired with coffee (50–69), or sick with bandages (0–49). **Scoring is handled by `checkup-score.js` — you MUST NOT calculate scores yourself. Your role is to collect raw facts, assemble them into structured JSON, and pass to the script.** **Argument parsing**: Extract from `$ARGUMENTS`: - `--format json` flag: skip HTML generation and write the checkup JSON to a file instead - `--output ` flag: path for the JSON output file (required when `--format json` is used; defaults to `/tmp/agentguard-checkup-data.json` if omitted) If `--format json` is present, follow the modified flow noted in Step 4 below. Plain `checkup` must always run this comprehensive workflow, even if the user phrases it as `agentguard checkup`. Do not answer that an advisory ID is required. Advisory IDs are optional and only switch to the targeted threat-feed self-check mode described below. If the arguments include `--against-advisory `, do not run this comprehensive HTML workflow. Instead execute the CLI threat-feed self-check: ```bash agentguard checkup --against-advisory agentguard checkup --against-advisory --json ``` That CLI path fetches the current Cloud advisory feed and checks local skills against the single advisory. It is separate from the full health report below. ### Step 1: Data Collection **IMPORTANT: You MUST run ALL 7 checks below — not just the skill scan. The checkup covers 5 security dimensions, not just code scanning. Do NOT skip checks 2–7.** **EVIDENCE RULE: Every finding you report MUST be backed by actual tool output collected in this step. You MUST quote the exact command output (or "no output" if the command returned nothing) in the finding's evidence field. Findings without concrete evidence from tool execution are FORBIDDEN — do not infer, assume, or fabricate results.** Run these checks in parallel where possible. These are **universal agent security checks** — they apply to Claude Code, OpenClaw, Hermes, and DSH environments, regardless of whether AgentGuard is installed. 1. **[REQUIRED] Discover & scan installed skills and DSH plugins** (→ feeds Dimension 1: Code Safety): Glob ALL of the following paths for `*/SKILL.md`: - `~/.claude/skills/*/SKILL.md` - `~/.openclaw/skills/*/SKILL.md` - `~/.openclaw/workspace/skills/*/SKILL.md` For **every** discovered skill, run AgentGuard DeepScan (`/agentguard scan `). Do NOT skip any skill regardless of how many are found. Record for each skill: name, risk_level, and exact findings list (rule, severity, file, line). Also discover installed DSH plugins under the resolved DSH home: use the non-empty `DSH_HOME` value when set, otherwise use the current user's real home directory plus `.dsh` (do not pass a literal unexpanded `~` to path APIs). Inspect `${dshHome}/profiles/*`; read each immediate profile's `package.json`, collect only names declared in `dependencies` and `optionalDependencies`, and resolve their existing directories beneath that same profile's `node_modules/`. For a dependency that declares `dsh.bundle.patch`, parse its Cordis patch and recursively resolve only package dependencies actually named by plugin rows in that patch; repeat for referenced child bundles, with path deduplication, cycle detection, and a bounded depth. Do not enumerate or scan unrelated transitive dependencies. Exclude only the exact `@axorasec/agentguard` dependency coordinate declared by the profile or referenced by a bundle; never trust an installed plugin's self-reported package name for this exclusion. For **every** discovered direct or bundle-referenced plugin, run `agentguard dsh-scan --format json` and record its name, path, `riskLevel`, and exact findings list (`ruleId`, severity, file, line), normalized to the raw-facts schema below. A failed DSH plugin scan must not prevent the remaining checks from completing; record it in `dsh_plugins` with `risk_level: "high"` and one finding `{ "rule": "DSH_SCAN_FAILED", "severity": "HIGH", "file": "", "line": 0 }`. 2. **[REQUIRED] Credential file permissions** (→ feeds Dimension 2: Credential Safety): Platform-aware check — behavior differs by OS: - **macOS/Linux**: Run `stat -f '%Lp' 2>/dev/null || stat -c '%a' 2>/dev/null` on `~/.ssh/`, `~/.gnupg/`. **If the command returns empty output, the directory does not exist — record `exists: false`.** - **Windows**: `stat` is not available. Use `icacls ` to check ACLs instead. If directory doesn't exist, record `exists: false`. If it exists, record whether the ACL grants access to `Everyone`, `Users`, or `Authenticated Users`. - Also check OpenClaw config files if applicable (`$OC/openclaw.json`, `$OC/devices/paired.json`). 3. **[REQUIRED] Sensitive credential scan / DLP** (→ feeds Dimension 2: Credential Safety): Use Grep to scan **all** agent workspace directories for leaked secrets. This MUST cover the entire workspace root, not just the current agent's directory: - For OpenClaw: scan `~/.openclaw/workspace/` recursively - For Claude Code: scan `~/.claude/` recursively - For Hermes Agent: scan `~/.hermes/` recursively - Patterns to detect: - Private keys: `0x[a-fA-F0-9]{64}`, `-----BEGIN.*PRIVATE KEY-----` - Mnemonics: sequences of 12+ BIP-39 words, `seed_phrase`, `mnemonic` - API keys/tokens: `AKIA[0-9A-Z]{16}`, `gh[pousr]_[A-Za-z0-9_]{36}`, plaintext passwords - Record: `private_keys_found`, `mnemonics_found`, `api_keys_found` (boolean, with location if found). - **Important**: Use the workspace *root* directory as the scan target (e.g. `~/.openclaw/workspace/`), not a specific agent subdirectory. All sibling `workspace-agent-*` directories must be included. 4. **[REQUIRED] Network exposure** (→ feeds Dimension 3: Network & System): Run `lsof -i -P -n 2>/dev/null | grep LISTEN` or `ss -tlnp 2>/dev/null` to check for dangerous open ports (Redis 6379, Docker API 2375, MySQL 3306, MongoDB 27017 on 0.0.0.0). Record list of dangerous ports found (e.g. `["Redis on 0.0.0.0:6379"]`). 5. **[REQUIRED] Scheduled tasks audit** (→ feeds Dimension 3: Network & System): Check `crontab -l 2>/dev/null` for suspicious entries containing `curl|bash`, `wget|sh`, or accessing `~/.ssh/`. Record list of suspicious cron command strings found. 6. **[REQUIRED] Environment variable exposure** (→ feeds Dimension 3: Network & System): Run `env` and check for sensitive variable names (`PRIVATE_KEY`, `MNEMONIC`, `SECRET`, `PASSWORD`) — detect presence only, mask values. Record list of sensitive variable names found. 7. **[REQUIRED] Runtime protection check** (→ feeds Dimension 4: Runtime Protection): Check if security hooks exist in `~/.claude/settings.json`, `~/.openclaw/openclaw.json`, or `~/.hermes/config.yaml`. Check for audit logs at `~/.agentguard/audit.jsonl`. Check if installed skills have been previously scanned (audit log contains `scan` events). Record booleans: `hooks_installed`, `audit_log_exists`, `skills_ever_scanned`. **Completion barrier:** Parallel collection is allowed, but Step 2 MUST NOT begin while any skill scan, DSH plugin scan, bundle-child discovery, or other required check is still running. Await every spawned/background task, collect every exit status and output, and only then assemble raw facts. Never start `checkup-score.js` or `checkup-report.js` from the same parallel batch as a scan. ### Step 2: Assemble Raw Facts JSON After completing all 7 checks, assemble the raw facts into a structured JSON and write it to a temporary file (e.g. `/tmp/agentguard-raw-facts.json`): ```json { "skills": [ { "name": "", "risk_level": "", "findings": [ { "rule": "", "severity": "", "file": "", "line": } ] } ], "dsh_plugins": [ { "name": "", "path": "", "risk_level": "", "findings": [ { "rule": "", "severity": "", "file": "", "line": } ] } ], "credential_files": { "ssh_dir": { "exists": , "permissions": "" }, "gnupg_dir": { "exists": , "permissions": "" }, "openclaw_config": { "exists": , "ok": } }, "dlp": { "private_keys_found": , "mnemonics_found": , "api_keys_found": }, "network": { "dangerous_ports": [""], "suspicious_crons": [""], "sensitive_env_vars": [""], "openclaw_config_ok": }, "runtime": { "hooks_installed": , "audit_log_exists": , "skills_ever_scanned": } } ``` **Pre-Step-3 validation** — verify all fields are populated before proceeding: - [ ] `skills` — from check 1 - [ ] `dsh_plugins` — from check 1; use an empty array when no DSH plugins are installed - [ ] `credential_files` — from check 2 - [ ] `dlp` — from check 3 - [ ] `network` — from checks 4, 5, 6 - [ ] `runtime` — from check 7 **If any field is missing, go back and run the missing check. Do NOT proceed with incomplete data.** ### Step 3: Compute Scores with checkup-score.js Run the scoring script (it reads the raw facts and deterministically computes all dimension scores, composite score, and tier — do NOT calculate these yourself): ```bash cd && node scripts/checkup-score.js --file /tmp/agentguard-raw-facts.json ``` The script outputs a JSON object with: - `composite_score` (0–100) - `tier` (S/A/B/F) and `tier_label` - `total_findings` - `dimensions`: `code_safety`, `credential_safety`, `network_exposure`, `runtime_protection` — each with `score` and `findings[]` Capture this JSON output — you will use it in Step 4. ### Step 4: Generate Analysis Report Based on the scored output from Step 3 and the raw facts you collected, write a **comprehensive security analysis report** as a single text block. This is where you use your AI reasoning ability — don't just list facts, **analyze** them: - Summarize the overall security posture in 2-3 sentences - Highlight the most critical risks and explain **why** they matter (e.g. "Your ~/.ssh/ permissions allow any process running as your user to read your private keys, which means a malicious skill could silently exfiltrate them") - For each major finding from the scored output, provide a specific actionable fix (exact command to run) - Note what's going well — acknowledge secure areas - If applicable, explain attack scenarios that the current configuration is vulnerable to - Keep the tone professional but direct, like a security consultant's report This report goes into the `"analysis"` field of the final JSON. Also generate a list of actionable recommendations as `{ "severity": "...", "text": "..." }` objects for the structured view. ### Step 5: Generate HTML Report Assemble the final JSON by merging the scored output from Step 3 with the analysis from Step 4, then pass it to the report generator: ```json { "timestamp": "", "composite_score": , "tier": "", "dimensions": { "code_safety": { "score": , "findings": [...], "details": "" }, "credential_safety": { "score": , "findings": [...], "details": "" }, "network_exposure": { "score": , "findings": [...], "details": "" }, "runtime_protection": { "score": , "findings": [...], "details": "" } }, "skills_scanned": , "dsh_plugins_scanned": , "dsh_plugins": [ { "name": "", "path": "", "risk_level": "", "findings": [ { "rule": "", "severity": "", "file": "", "line": } ] } ], "protection_level": "", "analysis": "", "recommendations": [ { "severity": "HIGH", "text": "..." } ] } ``` **If `--format json` was specified**: 1. Write this JSON to the `--output ` path (or `/tmp/agentguard-checkup-data.json` if no `--output` given) using the Write tool. 2. Tell the user: "Checkup JSON written to ``." — include the composite score and tier in the message. 3. **Stop here** — skip Steps 5 and 6 (HTML generation and MEDIA delivery). The terminal summary in Step 5 is also skipped since the user is consuming the raw JSON programmatically. **Otherwise (default HTML flow)**: Write the JSON to a temporary file using the Write tool (e.g. `/tmp/agentguard-checkup-data.json`), then run (remember to `cd` into the skill directory first — see "Resolving Script Paths" above): ```bash cd && node scripts/checkup-report.js --file /tmp/agentguard-checkup-data.json ``` The script outputs the HTML file path to stdout (e.g. `/tmp/agentguard-checkup-1234567890.html`). Capture this path — you will need it for delivery in Step 7. > **Note**: The script also supports stdin pipe (`echo '' | node scripts/checkup-report.js`) but this may fail on Windows cmd.exe. Always prefer `--file`. ### Step 6: Terminal Summary (REQUIRED) **You MUST output this summary after the report generates.** This is the primary output the user sees. Do NOT skip this step — always show the score, dimension table, and report path: ``` ## 🦞 Axora AgentGuard Health Checkup **Overall Health Score**: / 100 (Tier —