|
| 1 | +--- |
| 2 | +name: secretzero-agent |
| 3 | +description: | |
| 4 | + Use for agentic and operational SecretZero workflows including unified |
| 5 | + `agent sync`, CLI/API parity, secure human-in-the-loop vectors, and |
| 6 | + automation-safe run loops. |
| 7 | +--- |
| 8 | + |
| 9 | +# SecretZero Agent Skill |
| 10 | + |
| 11 | +Use this skill when running SecretZero in agentic workflows (manual-assisted, web-assisted, or fully automated), or when guiding users through runtime usage scenarios. |
| 12 | + |
| 13 | +## Install / Verify |
| 14 | + |
| 15 | +Preferred install: |
| 16 | + |
| 17 | +```bash |
| 18 | +uv tool install -U "secretzero[all]" |
| 19 | +``` |
| 20 | + |
| 21 | +Lean or provider-specific installs: |
| 22 | + |
| 23 | +```bash |
| 24 | +uv tool install -U secretzero |
| 25 | +uv tool install -U "secretzero[aws]" |
| 26 | +uv tool install -U "secretzero[azure]" |
| 27 | +``` |
| 28 | + |
| 29 | +Alternative: |
| 30 | + |
| 31 | +```bash |
| 32 | +pip install -U "secretzero[all]" |
| 33 | +``` |
| 34 | + |
| 35 | +Verify CLI: |
| 36 | + |
| 37 | +```bash |
| 38 | +secretzero --help |
| 39 | +secretzero agent sync --help |
| 40 | +``` |
| 41 | + |
| 42 | +## Core Agent Contract |
| 43 | + |
| 44 | +**Absolute rule:** `skills/secretzero/SKILL.md` — never consume secrets in context; use SecretZero for all handling (`agent sync`, `--web`, validate, status). Never request, receive, or print plaintext secret values. |
| 45 | +- Prefer JSON output for machine handling. |
| 46 | +- When running in automation or spill-sensitive hosts, set **`SZ_AGENT_MODE=true`** so the CLI blocks or redacts commands that would dump secret-bearing config (see `skills/secretzero-handle/SKILL.md`). |
| 47 | +- Use the unified entrypoint: |
| 48 | + |
| 49 | +```bash |
| 50 | +secretzero agent sync --json [--web] [--dry-run] [--verbose] |
| 51 | +``` |
| 52 | + |
| 53 | +## Three Usage Vectors |
| 54 | + |
| 55 | +1. **Human-instructed (Vector 1)** |
| 56 | + - Run `secretzero agent sync --json`. |
| 57 | + - Relay `pending_secrets[].summary` and ordered `steps` exactly. |
| 58 | + - Re-run until clean. |
| 59 | + |
| 60 | +2. **Secure local web capture (Vector 2)** |
| 61 | + - Run `secretzero agent sync --web` (add `--json` only when you also need structured stdout after the run finishes). |
| 62 | + - **Do not block the whole agent session on the foreground TTY if your environment allows it:** start the command in a **background terminal** (or equivalent job control) on the operator’s machine so the process can stay alive until the form is submitted, and **capture stdout** if you need to quote the URL line back reliably. |
| 63 | + - When the CLI prints the localhost URL, **relay the complete URL verbatim** to the user (scheme, host, port, and path — no truncation). Vector 2 binds to `127.0.0.1`; the printed URL is the handoff surface (this is **not** the same as `secretzero web`, which uses a separate **bootstrap token** for the network dashboard — if you use that command, pass through its **full login URL including the token** per that command’s output). |
| 64 | + - Remind the operator **not to paste secret values into chat**; only the URL and UI instructions belong in the agent thread. |
| 65 | + - Remind the operator to **submit the form once** and close the browser tab when done: the CLI helper **stops the temporary localhost server** after a successful submit; if they walk away, **Ctrl+C** (or waiting for timeout) ends the wait. |
| 66 | + - **API Vector 2:** `POST /agent/sync` with `web: true` returns `web_url` and `web_session_id` — give the operator the **exact `web_url`**, poll `GET /agent/sync/web/{web_session_id}` until `done`, and treat the session id as sensitive correlation data. The API process may keep that localhost port open until restart; do not forward `web_url` beyond the trusted operator. |
| 67 | + - Poll/re-run `agent sync --json` until `pending_secrets` clears. |
| 68 | + |
| 69 | +3. **Fully automated (Vector 3)** |
| 70 | + - Ensure provider auth is available (and optionally `SZ_AGENT=true`). |
| 71 | + - Run `secretzero agent sync --json`. |
| 72 | + - Handle `failed_secrets` with manifest fixes and retry. |
| 73 | + |
| 74 | +## Agent runtime integration |
| 75 | + |
| 76 | +When bootstrapping or restoring Hermes/OpenClaw installs: |
| 77 | + |
| 78 | +```bash |
| 79 | +secretzero agent list --format json |
| 80 | +secretzero agent adopt --dry-run --format json |
| 81 | +secretzero agent adopt --preseed-lockfile --format json |
| 82 | +``` |
| 83 | + |
| 84 | +Load `skills/secretzero-agent-adopt/SKILL.md` for the full adopt/restore playbook. `agent backup` is an alias of `agent adopt` (not `secretzero backup create`). |
| 85 | + |
| 86 | +## Standard Agent Loop |
| 87 | + |
| 88 | +1. Run `secretzero agent sync --json` first; escalate to `--web` when you need the localhost form (see Vector 2 handoff above). |
| 89 | +2. Parse status and `pending_secrets`/`failed_secrets`. |
| 90 | +3. Execute the appropriate vector behavior. |
| 91 | +4. Re-run command until both arrays are empty. |
| 92 | +5. Continue downstream only after clean completion. |
| 93 | + |
| 94 | +## API Parity |
| 95 | + |
| 96 | +Use API when running remote orchestration: |
| 97 | + |
| 98 | +- `POST /agent/sync` with `{ dry_run, web, lockfile?, sz_agent? }` |
| 99 | +- For Vector 2 polling: `GET /agent/sync/web/{session_id}` |
| 100 | + |
| 101 | +Treat API payload semantics the same as CLI semantics. |
| 102 | + |
| 103 | +## Operational Playbooks |
| 104 | + |
| 105 | +- **Agent adopt (Hermes/OpenClaw):** see `skills/secretzero-agent-adopt/SKILL.md` — `agent list` → `agent adopt` → `agent sync` |
| 106 | +- **Bootstrap:** `validate` -> `init --install` -> `test` -> `agent sync --json` |
| 107 | +- **Preflight:** `secretzero sync --dry-run` before mutating runs |
| 108 | +- **Maintenance:** pair with `secretzero rotate`, `secretzero drift`, `secretzero status --format json` |
| 109 | + |
| 110 | +## Common Failure Handling |
| 111 | + |
| 112 | +- Missing extras/provider dependencies -> run install/`secretzero init --install` |
| 113 | +- Auth missing/expired -> fix provider auth, re-run `secretzero test` |
| 114 | +- Manual-seeded secret lacks instructions -> add `agent_instructions`, retry |
| 115 | +- Variable interpolation issues -> check vars and `--var-file` usage |
| 116 | + |
| 117 | +## Definition of Done |
| 118 | + |
| 119 | +- Secret bootstrap/sync flow reaches no pending or failed secrets. |
| 120 | +- Workflow used secure vector handling with no secret leakage. |
| 121 | +- CLI/API behavior stays consistent for the selected scenario. |
0 commit comments