Skip to main content
skill CX Codex

harden · dshakes — Claude Code security skill: what it does, how to install

Five compass commands run in order: secrets in the staged diff, MCP version pins, install drift, release attestation, and untrusted code inside a sandbox.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add dshakes/compass --skill harden -a claude-code
Open on GitHub

What harden does

The skill walks five steps in sequence and stops on the first failure so you can fix it before moving on. Step 1, compass scan --staged, reads the staged diff for secrets; exit code 1 means one is sitting in your changes. Step 2 is bash scripts/check-mcp.sh: every auto-installed MCP server must carry an exact version, with no @latest float and no injection marker. A floating pin gets fixed in mcp/servers.json. Step 3, compass drift, compares the installed config under ~/.claude against this repo's sources. Step 4, compass verify, checks the keyless SLSA attestation on the latest release tarball and needs gh installed. Step 5, compass sandbox -- <cmd>, runs an untrusted command with no network and writes limited to cwd and tmp.

That sandbox needs a backend: bwrap, firejail or sandbox-exec. Without one the CLI refuses to run your command unconfined, so install bwrap or firejail first. On an older gh, the provenance check can exit with 77; that is a deliberate skip rather than a failure.

What you get is the mechanical layer. Findings that need human judgement stay with /security-review, run on the diff. Wiring compass scan --staged into .git/hooks/pre-commit makes the secret sweep fire on every commit instead of only before a PR.

What it helps with

  • catch a secret in staged changes before pushing
  • flag an MCP server with a floating version or injection marker
  • detect a hand-edited agent config that drifted from the repo
  • check SLSA attestation on a release tarball
  • run fetched code confined, with no network

Example prompts for the agent

  • Run the harden steps in order and tell me where it stopped
  • Scan the staged diff for secrets with compass scan --staged
  • Run compass drift and explain why the installed config no longer matches the repo

How to install harden

1Skills CLI (Vercel)

npx skills add dshakes/compass --skill harden -a claude-code

2Manually: put the files in place

~/.claude/skills/harden/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/harden/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about harden

How do I install harden in Claude Code?

Run npx skills add dshakes/compass --skill harden -a claude-code; the skill lands at ~/.claude/skills/harden/SKILL.md.

What does harden do?

It runs five compass commands one after another: a secret scan of the staged diff, an MCP pin audit, install drift detection, release attestation verification and a sandboxed run of an untrusted command.

What does the sandbox step require?

A working isolation backend: bwrap, firejail or sandbox-exec. Without one, compass sandbox will not execute the command unconfined.

Source text

SKILL.md · MIT
---
name: harden
description: Run the toolkit's security commands in order to surface secrets, MCP supply-chain issues, install drift, release provenance gaps, and untrusted-code risks before shipping. Use before opening a PR, after adding a dependency, or whenever the security posture needs a fresh check.
argument-hint: "[optional: -- <cmd> to sandbox-test a specific command]"
allowed-tools: Read, Grep, Glob, Bash
---

# Harden — security sweep in five ordered steps

Run each command in sequence. Stop on a non-zero exit and fix the finding before
proceeding. All five must pass before the branch is considered hardened.

## Steps

### 1 · Secrets — `compass scan --staged`
Scan the staged diff for secrets at the commit boundary.

```
compass scan --staged
```

Exits 0 (clean) or 1 (secrets found). Fix: remove the secret, rotate the
credential, then re-stage. Add an `# allowlist secret` comment ONLY for
confirmed test fixtures — never real credentials.

### 2 · MCP supply-chain pins — `scripts/check-mcp.sh`
Verify every auto-installed MCP server is pinned to an exact version and that
no `@latest` float or shell-injection marker has crept in.

```
bash scripts/check-mcp.sh
```

Exits 0 (pinned + clean) or non-zero (floating version or injection marker).
Fix: pin the version in `mcp/servers.json` and re-run. (`setup-mcp.sh` runs this
same audit as a pre-flight, and `compass doctor` includes it.)

### 3 · Install fidelity — `compass drift`
Check that the installed `~/.claude` config still matches this repo's source.
Catches hand-edited copies, stale hooks, and non-executable guardrail scripts.

```
compass drift
```

Exits 0 (in sync) or non-zero (drift detected). Fix: re-run `quickstart.sh`
or remove the hand-edited file and let the install re-link it.

### 4 · Release provenance — `compass verify`
Verify the latest release tarball's keyless SLSA attestation. Requires `gh`.

```
compass verify
```

Exits 0 (attestation valid), 77 (gh lacks attestation support — skip), or
non-zero (attestation missing or invalid). A 77 is a safe skip on old gh
versions; anything else is a provenance gap to investigate.

### 5 · Untrusted code — `compass sandbox -- <cmd>`
Run any untrusted command inside a real OS sandbox (no network, writes confined
to cwd/tmp via bwrap/firejail/sandbox-exec). Required before executing code
fetched from external sources.

```
compass sandbox -- <cmd>
```

Exits 0 (ran confined), 2 (usage error — supply a command), or non-zero if the
sandboxed command itself fails. If no backend is available the CLI refuses to
run the command unconfined — install bwrap or firejail first.

## Notes
- Run the five steps in order; each one gates the next in severity.
- `compass scan --staged` should also be wired as a pre-commit hook
  (`compass scan --staged` in `.git/hooks/pre-commit`) for continuous coverage.
- Security (`compass scan`, `compass verify`) and drift detection (`compass drift`)
  are also surfaced in `compass dashboard` for a fleet-wide view.
- This skill does not replace a full `/security-review` — it gates the mechanical
  checks. Run `/security-review` on the diff for human-judgment findings.

© dshakes · MIT · dshakes/compass

Similar skills

All skills for Security →

harden by other authors comes first.

From the same set3

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor