back
loading skill details...
Use before ClawHub export: audit skill, fix local + public.
---
name: skill-export-audit
description: "Use before ClawHub export: audit skill, fix local + public."
version: 1.2.2
author: Maxwell McClure
license: MIT-0
metadata:
hermes:
tags: [clawhub, skills, publishing, audit, workflow]
related_skills: [skill-import-audit, skill-import-harvest, hermes-agent]
---
Audit a local Hermes skill before exporting it to a community registry (ClawHub), and make sure BOTH the local skill and the public version end error-free. Incorrect data is worse than no data: a skill containing a wrong claim is worse than one missing it — delete anything you cannot verify rather than softening it. User-confirmed, user-observable claims (e.g. "verified in-visor (user-confirmed)") ARE verified data: keep them with the attribution. What gets deleted is unattributed, unverified content.
## When to Use
- Publishing a session-built skill to ClawHub (or any registry) for the first time, or as an update.
- The user asks to "clean up / prepare / audit" a skill before upload.
- A published version was found to contain an error or was published from a bad tree, and both local and public copies must be corrected.
## Source of truth
The in-place skill directory (profile `skills/<name>/`) is the ONLY source of truth. Never edit a staged or published copy directly — every fix lands in-place first, then propagates via a corrected publish (Phase 7).
## Phase 1 — Inventory
`find <skill-dir> -type f` — list every file (SKILL.md, references/, scripts/, templates/). Note the leaf-file count: ClawHub's publish `fileCount` equals the number of files YOU sent (a stage that happens to carry the registry-generated `skill-card.md` counts one less than its on-disk file count — see Pitfalls) — use it to sanity-check that the publish carried everything.
Then run the SLUG-UNIQUENESS check BEFORE any other phase — a wrong first publish is expensive, because a pending submission cannot be retracted (Phase 7):
1. `clawhub whoami` → your owner handle.
2. `clawhub search <slug>` — is the bare slug already held by a publisher? If that publisher is not you, publishing under it creates a SHADOWED listing: bare `inspect`/`search`/slug-only installs resolve to their (most established) listing, yours is only reachable as `@<your-handle>/<slug>` — and your own owner-qualified checks keep passing, so the collision is invisible in every subsequent phase and only shows up in search. The dry-run's `latestVersion: null` is account-scoped ("no prior version under you"), NOT a slug-availability check — do not read it as a green light.
3. If the bare slug is held by someone else: verify descriptive UNIQUE candidates (`clawhub inspect <candidate>` → "Skill not found or unavailable" = free) and present the options with the evidence — the naming decision is the user's (Phase 4 has the full rules).
4. **Skillspector state check (existing slugs only) — before any other audit work.** Check what the scanner has already flagged on the slug's current latest version, so the decision about it is made up front rather than discovered after the publish: `clawhub inspect <slug> --json` → `latestVersion.version`, then `clawhub scan download <slug> --version <v> --json` → report ZIP → read `skillspector.json` (status, severity, issueCount; per issue: issueId, pattern, category, confidence, file, line, finding, remediation). If there are no findings (or no report exists yet — pending version, scan not run): note clean/unknown and continue. If there ARE flagged issues, this is a decision point, not information: present the findings (severity, file:line, pattern, one-line finding each) and ask the user whether to continue the audit/publish **as-is** (a new version triggers a fresh scan; the old findings may not reproduce) or to **address the findings first** (fold them into this audit's fix list — fix in-place so the replacement publishes with the flagged content resolved; a flagged latest version keeps the listing in the human-review queue until the replacement clears). Do not proceed past this point without the user's answer. In delegated (audit-only) mode the child records the findings in its report and the PARENT asks — a child cannot ask. A new slug has no published version: skip, note N/A. `clawhub scan --slug <s> --json` can return EMPTY with exit 0 — always use `scan download` and read the ZIP.
## Phase 2 — Accuracy audit (verify every claim class)
1. **Machine facts** → check against the live system (binary `--version`, install paths, config files).
2. **Engine/API claims** → verify against the LIVE binary: run a small introspection script (e.g. a Godot `-s` script using ClassDB) for defaults, full property lists, and — as important — what does NOT exist. A property that doesn't exist is a finding even when the skill correctly omits it; confirm the omission is right, and confirm error messages quoted in the skill actually fire. Structure the probe as enumeration FIRST (dump the full property/method lists before touching individual properties): an invalid property access is a runtime error that aborts the rest of the enclosing function, so a probe that hits a bad property name returns only the error and silently skips every remaining check.
3. **Code claims** → grep the actual project files the skill references (flags, node names, numeric values, binding counts).
4. **Bundled scripts** → review before you execute, then execute restricted. The scripts in `scripts/` are part of the artifact under audit, NOT trusted tooling: a compromised skill could ride this "run the scripts" step to make the agent run unreviewed code with its full permissions (stealing secrets, modifying files) — and the Phase 5 security screen runs AFTER Phase 2, so it does not retroactively protect this execution. Therefore: read every script in full FIRST and establish what it touches (files, environment, network, credentials); only after the source check passes, execute in a restricted context — scratch workdir, no credentials or secrets in the environment, synthetic/sanitized inputs first, real inputs only where the script's purpose needs them (a shipped scanner crashed on every real file until it was actually run) AND the reviewed source shows it touches nothing sensitive. A crash is an audit failure, not a note — fix it in-place AND re-run against the same inputs to confirm the fix. If the source does not check out or you cannot bound what it touches, do NOT run it: record the step as REVIEW-REQUIRED and let the user decide (a "didn't run" is never an audit pass). (Prompt-only skills have no `scripts/` — record the step as N/A, not a pass or a failure.)
5. **External facts** (upstream releases, file sizes, project abandonment) → web-verify against the primary source (the release page itself), not search snippets.
6. **Cross-file consistency** → every claim in SKILL.md must agree with the reference files. Contradictions between files are the highest-severity defect: one real case had a reference file teaching the exact opposite of the corrected lesson in SKILL.md.
Fix every defect in-place NOW — do not carry known-bad content into staging.
## Phase 3 — Machine-specifics removal
Grep the whole skill directory for machine-specific residue: drive-letter paths, "this machine", "the <project> has X", usernames, hostnames. Replace with either:
- generic phrasing ("a Windows host", `C:/path/to/<proj>` placeholders), or
- explicitly-labeled examples ("example: ...") — an example is not a claim, and is fine to keep.
Keep ecosystem facts that hold for every user of that ecosystem (e.g. a vendor's standard install path). Re-grep to zero before staging.
## Phase 4 — Metadata check
Frontmatter must match the public listing's conventions: same author, same license, description at least as good as the published one, tags complete. Version must be a bump over the server's latest (`clawhub inspect <slug> --json` → `latestVersion`), with a real changelog naming the substantive changes. Note the published version comes from the `--version` flag or the CLI's derivation ("1.0.0 or next patch" over the server's latest) — NOT from the frontmatter: when the frontmatter version is not exactly the CLI's next patch, pass `--version` explicitly and verify the version the dry-run reports. For a NEW slug, `inspect` errors with "Skill not found or unavailable to this account" and the dry-run reports `latestVersion: null` — that is confirmation the slug is unused FOR THIS ACCOUNT, not a failure; the first version is 1.0.0. Slugs can be DUPLICATED across owners: another publisher may already own the bare slug even when it is free for you (the dry-run's `latestVersion: null` is account-scoped — it was observed `null` for a slug another owner had published) — check `clawhub search <slug>` for the owner-scoped view. If the bare slug belongs to another publisher, publishing under it creates a SHADOWED listing: bare `inspect`/`search`/slug-only installs resolve to the other owner's (most established) listing, and yours is only reachable as `@<your-handle>/<slug>`. In that case recommend a descriptive UNIQUE slug, present the options with the evidence, and let the user choose — naming is the user's decision, not yours. If the frontmatter license differs from the public listing's license, align the FRONTMATTER to the listing (observed: frontmatter `MIT` listed as `MIT-0` — the listing is what readers see, and the frontmatter must match it).
## Phase 5 — Staging hygiene (contamination is the #1 real failure)
- Use a FRESH staging directory with a unique name per publish (e.g. `<name>-stage-<version>`). Never reuse a scratch dir: stale content has survived a forced re-copy of the stage dir and poisoned a real publish.
- Copy files explicitly, then `diff -r <in-place> <stage>` MUST be clean before any publish attempt.
- Windows: the ClawHub CLI is Node — pass drive-letter paths (`C:/...`); MSYS paths (`/c/...`) fail with exit 1.
- `--dry-run` first; check the **slug** (verify it matches the intended listing — omitted, it derives from the staging folder name), the version, `fileCount`, and read the publish-intent line: the CLI (v0.26.0) prints "Would publish <slug>@<ver>" for a real new version but "OK. <slug>@<ver> is already published" (JSON `status: "unchanged"`) when the version is not a bump — that second form is not a dry-run failure, it is the Phase 4 "not a bump" problem, and it means the real publish would be a no-op.
- **Pre-publish security screen (mandatory, same call as the publish):** the clean `diff -r` above only proves staging == source — if the SOURCE itself was tampered with (a compromised machine, a rogue process), the diff is still clean and the tampering ships. Screen the staged tree itself, immediately before `publish`, in the same command chain: (1) grep the staged tree for the same red flags skill-import-audit Phase 2 lists — credential paths, exfiltration URLs, pipe-to-shell, `eval`/`exec` on fetched content, hidden/zero-width characters, destructive patterns — any hit stops the publish — and screen CODE CONTEXT (URLs, commands, blobs), not prose: a case-insensitive `POST` matches "post-publish" in this very skill, so make patterns precise (a data-upload flag paired with a remote URL, `POST /` followed by a host) or every run drowns in false positives; (2) delta review — fetch the server-stored copy of the currently published version and diff it against the staged tree: only the intended changes may appear. `inspect` returns content for SKILL.md only (`skill.description`) — for a skill with any files beyond SKILL.md, install the published version and diff EVERY file: `clawhub install <slug> --version <server-version> --dir <scratch> --no-input` (CR-normalize per Phase 6 step 2; exclude install metadata `_meta.json`/`.clawhub/` and the registry-generated `skill-card.md` from identity checks). The install is the only CLI path to the full published file tree — `clawhub scan download` returns the scan REPORT, not the skill's files. Compare against the installed server copy, not the in-place tree: the in-place tree can differ from the public tree by file SET, in both directions (local-only helpers, registry files absent locally). If extra lines appear, READ them before deciding — the in-place tree can legitimately change under you between audit and publish (the skill system normalizes descriptions, bumps versions, adds standing rules; the user can edit too): accept such changes, re-stage, and continue. Only unexplained or suspicious changes stop the publish and force a re-audit from scratch (fresh skill with no published version: skip the delta, the pattern screen is the check). Ninja edits between audit and upload surface here.
## Phase 6 — Publish + verify what the server actually holds
Stop at `--dry-run` until the user explicitly confirms the real publish — dry-run is side-effect-free and safe to re-run, while the real publish is the workflow's one irreversible step (retraction is possible but costs a reserved version number — Phase 7). This pause is MANDATORY and is NOT satisfied by prior authorization: an original request like "audit and publish it" does not count as confirmation. Present the audit result and the dry-run output, then wait for a fresh, explicit go-ahead AFTER the user has seen that evidence.
1. After explicit confirmation, publish for real with an explicit `--slug <stable-slug>`, `--version <frontmatter version>`, and `--changelog <text>` (no dry-run); capture the `versionId` if the CLI prints one (it omits the id when the version goes straight into the pending queue — that is not an error; the inspect comparison is the verification). The slug must ALWAYS be passed explicitly: omitted, the CLI derives it from the folder name, and a unique staging dir (`<name>-stage-<version>`) would create a *new* listing at a new URL on every publish instead of bumping the existing one. Pass `--name <displayName>` explicitly as well: omitted, the registry derives the display name from the staging folder name, and a unique stage dir would corrupt the listing's display name on every publish.
2. `clawhub inspect @<owner>/<slug> --json` — ALWAYS owner-qualified (your handle from `clawhub whoami`): a BARE-slug inspect on a duplicated listing resolves to ANOTHER owner's listing and the comparison silently runs against the wrong skill (a real case: the post-publish compare matched a different publisher's SKILL.md instead of yours). The denormalized `skill.description` field shows the SKILL.md the server actually STORED — compare it against the local file AFTER normalizing line endings: the server stores lines with CR+LF terminators and the CR count per line is not stable (two CRs observed on one CLI build, one on v0.26.0) — always collapse all CR runs to single `\n` before comparing (`re.sub(r'\r*\n', '\n', text)`) — without that, EVERY publish looks like a mismatch. Residual mismatch = contaminated staging → Phase 7. Because the staged tree passed the Phase 5 security screen, server == local means the public content is exactly what was screened — this comparison IS the post-publish security verification.
3. A new version almost always sits in a pending security-scan queue (publish prints e.g. "Update submitted ... pending security scans before it becomes public") — do NOT re-publish "to push it through". Release is observed, not inferred: `latestVersion.version` does not equal the new version until the queue clears (observed: minutes to ~15 min). Do NOT poll in-session — the tool-call cap (~300 s) kills long poll loops and loses their output. ALWAYS schedule the wait as a one-shot cron: `cronjob_manage` with `action: create`, `name: "<slug> <version> publish verification"`, `schedule: "in 30m"`, and a self-contained prompt — jobs run in a fresh session with no chat context, so the prompt must carry the slug, the expected version, the local SKILL.md path, the line-ending normalization rule (step 2), the expected file count — and for a multi-file skill, the `clawhub install` command plus the metadata/card exclusions from Phase 5, so the job diffs every published file, not just SKILL.md (a fresh session cannot see this chat's file set) —, the note that the `moderation` object is top-level (NOT under `skill`), and the branch instructions: on pass → compare the server-stored copy against the STAGE DIRECTORY for that version (not the in-place tree — in-place may have legitimately moved on to the next version by the time the job runs; the stage dir is the exact tree that was published), then delete the job (`action: list`, then `remove` by its job_id) and report LIVE + compare result; if still pending → report STILL PENDING, delete nothing, re-publish nothing. Then end the turn with one line — "submitted, pending, monitor scheduled" — and let the job's report land in the chat.
4. Never report success from publish `ok:true` alone — the inspect comparison IS the verification.
## Phase 7 — Fix loop: local AND public must both end error-free
Any defect found in any phase (or discovered later) gets fixed in both copies, in this order:
1. Fix in-place (source of truth).
2. `clawhub delete <slug> --version <v> --yes` retracts one version. The CLI constraint is LATESTNESS, not release state: it withdraws "one non-latest version", and the current LATEST version cannot be retracted directly — publish the replacement first, then retract the bad version. A PENDING (queued) submission is NOT retractable by the owner at all: version retraction is permission-denied and whole-skill delete is refused ("currently hidden by moderation ... contact a moderator") — while a submission sits in the queue it is under moderation's control, not yours. Only once it goes live can it be deleted (whole-skill delete on a multi-publisher slug requires the owner-qualified ref — a bare slug is refused with "Slug is used by multiple publishers"). Consequence: a wrong-slug first publish leaves an orphan duplicate listing you can only remove AFTER it clears the queue — plan the slug before the first publish instead of renaming after. When a rename did happen, fold the superseded slug's state check into the new listing's Phase 6 verification cron: the orphan going live is the exact moment it becomes deletable, and the cron's report is when you learn that. Notes: `--reason` is only valid for whole-skill deletion — omit it for a version retraction; the server may report a version as already unavailable (observed in the original incident) — nothing left to retract, continue.
3. Retracted version numbers are RESERVED — bump past them (1.0.1 retracted → next publish is 1.0.2, never reuse 1.0.1).
4. Re-stage (fresh dir, `diff -r` verified) and publish the corrected version.
5. Verify the end state: in-place tree == staged tree == server-stored copy (via inspect), and no audited defect remains in either. Definition of done: **local and public are identical and error-free.**
## Delegation — run the heavy prefix in a subagent (optional)
Phases 1–5 are where context burns (file reads, probes, web verification, big diffs). When the audit is heavy (multiple files, live probes, web checks, or a full harvest), run them in a subagent and keep the main session for the boundary. The child loads this same skill, so the phases run verbatim — only the handoff changes:
- Spawn: `delegate_task` with the target skill dir, this skill's name (the child loads it via `skill_view`), the scratch dir, and the environment facts the child lacks (MSYS/native path split, the CR-normalization rule). The child has no chat, no clarify, no cronjob, no memory, no re-delegation: it cannot ask the user, so any decision point it reaches gets recorded in its report, and the parent never acts on a child's self-report.
- Audit-only mode: the child reports, never fixes — Phase 2's "fix in-place NOW" applies to the PARENT on receipt: the child's deliverable is findings plus recommended fixes, and the parent applies them in-place, re-stages, and re-verifies. (The child constraint and this skill's fix rule conflict by design; the handoff resolves it.)
- Deliverable contract: pass an EXPLICIT contract in the spawn context — an `output_schema` (JSON Schema) or an example payload, not a prose reference to the shape: a child handed an empty schema self-invents its own report shape, which the parent cannot machine-validate. The compact report carries (a) the version line found, (b) per-phase verdicts, (c) findings + recommended fixes, (d) the fresh stage dir's absolute path, (e) the exact dry-run output verbatim, and (f) one scratch evidence file holding ALL detailed working output (phase tables, grep hits, diffs, dry-run JSON). Heavy output belongs in the evidence file, not in the returned summary — that is the entire point of the pattern.
- Parent on receipt: read the evidence file (the child's summary is an index, not a verdict), re-run the dry-run yourself (side-effect-free) so the presented evidence is parent-owned, then present everything at the Phase 6 stop-boundary. A child's "dry-run green" is not evidence; your re-run is.
- When NOT to delegate: one-file, minor-delta audits — spawn-and-relay overhead exceeds the context saved.
## Context management — survive compaction without losing state
Long audits can cross the context limit; compaction (runtime-automatic, or the user's in-session `/compress`) summarizes history and can land mid-phase. Make that harmless:
- Context is a cache; the scratch dir is the source of truth. After each phase, if its output will be needed later, persist it to a scratch file BEFORE moving on (staging is disk-native; audit tables and probe output must be written out, not merely displayed).
- If this run continues from a compaction summary: re-derive state from disk (stage dir, evidence files, version line, cron list) — never trust the summary's "in progress" narrative. Re-read this skill if it was pruned from context. Never assume the Phase 6 boundary was already presented/approved — if it is not verifiable in visible history, re-present the evidence. Never re-publish on a summary's "published" claim — verify with a fresh inspect.
- Optional clean compaction point: after the heavy verification phases, once the evidence is on disk, you may suggest to the user a manual `/compress` (a user command — not a tool you can call) — compacting at a phase boundary with durable state on disk loses nothing.
## Pitfalls
- A clean `diff -r` is not a security check: it proves staging matches source, and a tampered source diffs clean. The staged tree itself must pass the Phase 5 pre-publish screen — in the same call as the publish, so no window remains for a ninja edit.
- Waiting for the pending queue by polling in-session burns the turn: the tool-call cap (~300 s) kills the loop and its output is lost. The 30-minute one-shot cron IS the wait (Phase 6 step 3) — end the chat turn with a one-line status and let the job's report land in the chat.
- Staging-dir reuse poisons the publish (real case: a stale pre-audit tree was published as 1.0.1 with the old content under a new version number). Fresh dir + `diff -r` every single time.
- `inspect` shows what the server STORED, not what you SENT — always the post-publish check.
- The current LATEST version cannot be retracted — publish the corrected version first, then retract the bad one; plan the version bump before you need it, not after.
- After the pending queue clears, a version can still land in a HUMAN review queue with a clean verdict: `moderation.reasonCodes` carries `review.llm_review` (`legacyReason: scanner.llm.review`) — the dashboard shows "needs review" while the skill stays live, public, and installable; verdict-only checks read it as clean. It is not a block and nothing is retractable: download the scanner's findings with `clawhub scan download <slug> --version <v>` (ZIP → `clawscan.json` per-dimension ratings/summary/guidance PLUS `skillspector.json` — the per-finding detail the dashboard renders: issueId, pattern name, severity, confidence, matched string, start/end lines, remediation; also `endor.json`, `manifest.json` — `manifest.json`'s `artifact.fileCount` + `sha256hash` reveal the published package's composition without installing). `clawhub scan --slug <s> --json` can return EMPTY output with exit 0 — always use `scan download` and read the ZIP. Then decide between waiting for the moderator or fixing the flagged content and republishing.
- Static scanner findings can be FALSE POSITIVES on quoted command tokens in prose: a "Tool Parameter Abuse" (HIGH) hit matched the literal `rm`-`-rf`/`cp`-`-r` command tokens inside a pitfall WARNING, not an instruction. Check the matched string and line before "fixing" a finding; when the hit is quoted prose, rephrase to drop the literal token while keeping the lesson — this defuses the static re-match on the next scan without weakening the content (the LLM review layer already understands context; the static flag is what feeds the human-review queue). The same rephrase covers Anti-Refusal (AR2) hits: factual engine notes like "no error, no warning in the log" read as instructions to suppress caveats — reword to "the engine prints nothing to the log". The mirror image decides which remedy a finding gets: MEDIUM-confidence Output-Handling findings about data loss or system-wide changes (an overwrite step with no backup, a machine-wide setting changed without warning) usually flag a REAL content gap — add the backup/record-restore wording the remediation asks for instead of rephrasing around it.
- A just-published version may not appear in `stats.versions` / `--versions` until the pending queue clears (observed behavior); that is normal, not a lost publish. While pending, `inspect` returns `skill: null` / `latestVersion: null` — only the top-level `moderation` object is populated, with `legacyReason: "pending.publication"` and the scan verdict: the step-2 content comparison is impossible until the listing goes live, and that is exactly what the step-3 cron exists to do.
- Publishing a newer version while an older one is still pending is fine: the queue processes submissions in order, both clear, and `latestVersion` ends at the newest — do not "wait for the queue to drain" before publishing a newer fix.
- MSYS/native path split: bash builtins take `/c/...`; native tools (Node CLI, Python, Blender) need `C:/...`. Redirects to `/tmp` inside a mixed bash+native call also fail — use an explicit scratch path. Related trap: an inline `python -c` screen inside a `set -e` publish chain aborts the WHOLE chain (publish never runs) if the Python text contains backticks — bash chokes on them before execution; keep inline screens backtick-free or write the snippet to a scratch file first.
- `clawhub search` lists slugs that can be DUPLICATED across owners, and `inspect` has no `--owner` flag — disambiguate as `@owner/slug` (`clawhub inspect @owner/slug`; your handle comes from `clawhub whoami`); a bare-slug inspect on a duplicated listing fails or can hit the wrong owner.
- The in-place skill tree is mutable under you: the skill system can rewrite or add files mid-session (observed: a frontmatter description was normalized after staging; a reference file appeared between audit passes) — re-run `diff -r` immediately before the REAL publish and re-stage if it is dirty. A diff that was clean minutes ago is not a diff that is clean now.
- The server's `--files` listing includes a server-generated `skill-card.md` (present in every version, regenerated per version — size/hash changes without any publisher-side change). It is not a file from your tree: `fileCount` counts only the files you sent, and the CLI's auto-generated changelog can carry spurious bullets about it (observed: "removes skill-card.md" on a publish that never contained one). Pass `--changelog` explicitly to keep the public record clean; expect `skill-card.md` in file-set comparisons and exclude it from tree identity.
- The child pattern (Delegation) never moves the Phase 6 boundary: a child cannot ask the user, so the stop-boundary always lands in the main session — and a child's "dry-run green" is a self-report, never the evidence you present.
don't have the plugin yet? install it then click "run inline in claude" again.