/lstack-extras:security-setupfrom lstack-extras
Installs a local-first security hardening stack with pre-commit hooks for secret detection, dependency scanning, and static analysis. Gated two-phase setup: local baseline then optional CI mirror.
Ships in lstack-extras. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Install a local-first security hardening stack for a project. Favor checks that run offline at hook time, produce machine-readable output, and give developers a clear summary before code leaves their machine.
This skill may trigger automatically per its description, but it never writes
silently: Phase 1 always dry-runs the planned changes and waits for explicit
user confirmation before touching files, and Phase 2 (CI) only runs when the
user explicitly asks for it (e.g. --ci).
.pre-commit-config.yaml, scripts/, security/, SECURITY.md.--ci) GitHub Actions enabled on the repo.Check these before Phase 1:
git rev-parse --git-dir. If it exits non-zero, stop and end with a BLOCKED final report.python3 --version (python --version on Windows). If no interpreter answers, or the version is below 3.8, stop and end with a BLOCKED final report.SECURITY.md and the final report. Do not claim offline coverage for it.Before creating/updating/deleting files in an existing repository, sync the current branch with remote:
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin
git pull --rebase origin "$branch"
If the working tree is not clean, stash first as a backup, sync, then restore:
git stash push -u -m "pre-sync" # backup local changes
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin && git pull --rebase origin "$branch"
git stash pop # rollback by restoring the backup
If origin is missing, pull is unavailable, or rebase/stash conflicts occur, stop
and ask the user before continuing. Never use --force rollback options without
confirmation.
Work in two gated phases:
--ci, create a free-tier
GitHub Actions workflow that runs the same local runner on pull requests.Do not create CI files until Phase 1 is installed and passing.
Inspect the repo before choosing tools. The runner and skill instructions work on macOS, Linux, and Windows; pick the matching shell snippet.
macOS / Linux (bash, zsh):
ls -la package.json package-lock.json pnpm-lock.yaml yarn.lock pyproject.toml requirements.txt Cargo.toml Cargo.lock go.mod pom.xml build.gradle 2>/dev/null
ls -la .pre-commit-config.yaml SECURITY.md .github/workflows/security.yml 2>/dev/null
command -v gitleaks trivy semgrep detect-secrets bandit cargo-audit pre-commit 2>/dev/null
Windows PowerShell:
Get-ChildItem -Force -ErrorAction SilentlyContinue package.json,package-lock.json,pnpm-lock.yaml,yarn.lock,pyproject.toml,requirements.txt,Cargo.toml,Cargo.lock,go.mod,pom.xml,build.gradle
Get-ChildItem -Force -ErrorAction SilentlyContinue .pre-commit-config.yaml,SECURITY.md,.github\workflows\security.yml
foreach ($t in 'gitleaks','trivy','semgrep','detect-secrets','bandit','cargo-audit','pre-commit') { Get-Command $t -ErrorAction SilentlyContinue }
Identify:
Use references/tool-selection.md for the tool matrix and install commands.
Choose the smallest useful set:
gitleaks; use detect-secrets when it already exists in
a Python-heavy repo.trivy fs --skip-db-update for offline hook runtime;
add cargo-audit only for Rust repos that already use Cargo.semgrep with local rules under security/.
Add language-native scanners only when the language is present (bandit for
Python, gosec for Go, cargo clippy/cargo audit for Rust).When the repo uses package managers, recommend Socket Firewall as a lightweight
local guardrail for day-to-day dependency installs. This does not replace lockfile
scanning with trivy/cargo-audit; it shifts risk left by making risky installs
harder before a new dependency reaches the repo.
For macOS/Linux users on zsh or bash, suggest adding these aliases to the
developer shell profile:
alias npm="sfw npm"
alias yarn="sfw yarn"
alias pnpm="sfw pnpm"
alias pip="sfw pip"
alias uv="sfw uv"
alias cargo="sfw cargo"
Only include aliases for package managers the project actually uses, and document
the guardrail in SECURITY.md as optional local developer setup. If Socket
Firewall is not installed, print the official install instructions or link to
the official docs; do not add failing hooks that require sfw.
The hook must not call cloud services at runtime. If a scanner needs a local
database, warm that database during setup and run with offline flags in the hook.
If offline dependency scanning cannot be configured for an ecosystem, document the
gap in SECURITY.md and do not pretend the criterion is satisfied.
Pre-commit must be fast on small commits without losing coverage. Each check declares its own relevance rule — never a global "skip on .md only" filter.
Trigger semantics in security/security-tools.json:
| Trigger | Behavior |
|---|---|
"always": true | Always run. Use for secret scanners — secrets land in .md, .json, .env.example, Dockerfile, anywhere. |
"paths": [globs] | Run only when at least one staged file matches a glob. Use for lockfile-driven (trivy, cargo-audit) or language-driven (semgrep, bandit) checks. |
| (omitted) | Runner falls back to the per-tool defaults baked into scripts/security_check.py for the recognized tool name. |
A repo-wide trip_all_paths list (default: .pre-commit-config.yaml, security/**,
.github/workflows/**, Dockerfile*, .dockerignore, scripts/security_check.py)
forces every applicable check to run when any of those files is staged. This
catches workflow-injection edits, hook-tampering, and Dockerfile RCE that would
otherwise slip past purely category-based scoping.
CI runs full scans (--all). Scoping only applies on developer commits; the CI
mirror is the safety net.
Mandatory invariant: secret scanning runs on every commit. Do not move gitleaks (or its replacement) into a path-restricted trigger.
Dry-run the changes before writing any file:
new or exists.exists target, show the diff between the current file and the planned content..pre-commit-config.yaml and SECURITY.md explicitly when they exist: overwriting either one is destructive.BLOCKED final report. If the user declines some files, write only the confirmed ones and record each declined file for the final report.exists target, copy it to <path>.bak so the user can roll back.Create or update these files:
.pre-commit-config.yaml - merge a local security-check hook into existing
config; do not overwrite user hooks.scripts/security_check.py - copy from scripts/security_check.py in this
skill, then adjust tool config if needed.security/semgrep-rules.yml - local Semgrep rules so runtime scans are offline.security/security-tools.json - selected tools and command overrides.SECURITY.md - summary of selected tools, why they were chosen, and how to run
or bypass checks.Use references/templates.md for starter snippets.
Never add a silent bypass. Bypass cannot be performed through git commit
because pre-commit redirects hook stdin to /dev/null, so the runner's
TTY check refuses --force from inside the hook. The approved bypass is a
two-step, explicit override:
Run the runner directly with --force and type YES at the prompt:
# macOS / Linux
SECURITY_CHECK_ARGS=--force python3 scripts/security_check.py
# Windows PowerShell
$env:SECURITY_CHECK_ARGS = "--force"; python scripts\security_check.py; Remove-Item Env:SECURITY_CHECK_ARGS
:: Windows cmd.exe
set SECURITY_CHECK_ARGS=--force && python scripts\security_check.py && set SECURITY_CHECK_ARGS=
The runner prints the prompt:
Type YES to override security checks and force-push:
It accepts only the literal string YES. Any other input, EOF, or a
non-TTY context exits non-zero and refuses the bypass.
After the override is recorded in the report, commit with
git commit --no-verify. Document the bypass in SECURITY.md (date,
reason, link to the recorded report) so the override is auditable.
Do not add --force to the pre-commit hook entry, and do not wrap
git commit in a script that opens /dev/tty for the hook — both routes
hide the bypass from review.
Run the local checks after writing files. Use python3 on macOS/Linux and
python on Windows (the Python launcher routes to the active interpreter).
Verification uses --all so every configured check runs regardless of what
happens to be staged.
First run pre-commit --version. If it exits non-zero, print the install
commands below, run only the security_check.py command, skip
pre-commit run, and end with a PARTIAL final report that names the
missing pre-commit:
python3 -m pip install pre-commit # use `python` on Windows
pre-commit install
If it exits 0, run both verification commands and record each exit code:
# macOS / Linux
python3 scripts/security_check.py --all --no-fail-on-missing-tools
pre-commit run security-check --all-files
# Windows PowerShell
python scripts\security_check.py --all --no-fail-on-missing-tools
pre-commit run security-check --all-files
When run from a pre-commit hook with no flags, the runner inspects
git diff --cached and scopes checks to the staged file set per the trigger
table in §2. --all overrides this for verification or one-off full scans;
--staged-only errors if no staged files are found (useful for guarded
hooks).
Exit codes: 0 means no failing finding (or an accepted bypass), 1 means
at least one fail_on finding, and 2 means the runner could not run (an
invalid security-tools.json, --staged-only with nothing staged, or an
unwritable report path); its stderr message names the input and the fix.
A successful first run prints a summary to stdout and exits 0. See "Report Requirements" below for the exact shape and content of that summary.
Assert: a clean run exits 0, both report paths exist, and
security-report.json parses as valid JSON with a top-level summary
object. Any HIGH or CRITICAL finding exits non-zero unless the bypass
in §"4. Bypass Policy" was completed.
--ci)Only run this phase when the user asks for CI/CD, for example
/security-setup --ci.
Preconditions:
python3 scripts/security_check.py --all --no-fail-on-missing-tools exits 0 locally.pre-commit-config.yaml contains the security-check hookIf any precondition fails, do not create the workflow; record CI not created
and the failing precondition for the final report.
Otherwise create .github/workflows/security.yml using references/templates.md.
If that file already exists, apply the Step 3 dry-run steps to it first
(diff, confirm, .bak backup). Keep the workflow free-tier friendly:
pull_request and push to the default branch.python3 scripts/security_check.py --all (CI always full-scans).The local runner must print a concise report with:
The default exit behavior is strict: any HIGH or CRITICAL finding exits
non-zero.
A successful full run looks like this (exact counts vary):
Security Check Summary
======================
Mode: full
Checks run: 3 of 3 (skipped: 0)
Findings: 1
Severity: HIGH=1
Categories: dependencies=1
JSON report: security/security-report.json
Markdown report: security/security-report.md
Top findings:
- HIGH [dependencies/trivy] CVE-XXXX-XXXX in <pkg> (<lockfile>)
Hint: Upgrade to <version>.
A scoped run on a docs-only commit looks like:
Mode: staged
Staged files: 2
Checks run: 1 of 3 (skipped: 2)
Skipped: trivy, semgrep
Skipped checks are recorded in both reports with their scope reason — they are not silent.
A completed setup passes when:
.pre-commit-config.yaml contains a local security-check hook.scripts/security_check.py exists and prints the required summary.--force requires the exact YES confirmation before bypassing failures.SECURITY.md documents selected tools, omissions, run commands, and CI
status.--ci creates .github/workflows/security.yml only after Phase 1 passes.references/verification-scenarios.md.references/final-report.md:
the status is on the first line, verified checks are separated from
assumptions, each claim cites a command or file, and the next decision is
named. Human understanding stays unconfirmed until the user gives feedback.security/security-tools.json and document
per-package coverage.references/tool-selection.md for each missing selected tool, and install it
only after the user confirms. A category whose tool stays missing is listed
in the final report; never skip it silently.After each phase, report:
◆ Security Setup ([phase] - [context])
................................................................
Project detection: pass | fail - detail
Tool selection: pass | fail - detail
Local hook: pass | fail - detail
Security report: pass | fail - detail
CI mirror: pass | skipped | fail - detail
Criteria: N/M met
____________________________
Result: PASS | PARTIAL | FAIL
End every run, including a stop, with one final report in the shape
references/final-report.md defines. Read it before writing the report. The
four parts are required, in this order:
Result: — COMPLETE, PARTIAL — <reason>, or BLOCKED — <reason>, then one line on what changed.Evidence: — only commands that ran, with exit codes, and each file written with its .bak path.Uncertainty: — missing tools, offline gaps, declined files, and checks that did not run.Decision: — the approval the user must give, or No approval needed., then each remaining user action.Optional and propose-only. After the run's result is delivered, run this check:
SECURITY.md, the dry-run file list, or the final report.--ci phase up front.references/ (the directory holding this SKILL.md). Bump the patch number of metadata.version. If the skill is an installed copy or tracked in git, say so. Commit nothing unless the user asks.Off — the user opted out.Read each file only when its step needs it, to keep the context window small.
references/tool-selection.md - offline-first tool matrix and install notesreferences/templates.md - target repo file templatesreferences/verification-scenarios.md - no-blindspot manual verification scenariosreferences/final-report.md - final report parts, status rules, and examplesscripts/security_check.py - reusable local security summary runnerWhat SKILL.md sets; muted values are Claude Code's defaults
highThree short reads, in order
npx claudepluginhub luongnv89/skills --plugin lstack-extras32 skills in this plugin
/agent-profileRun a task with a saved agent profile (harness, model, thinking level) built only from what this machine has installed. User-invoked: /agent-profile. Don't use for free opencode runs, Herdr or Rex fleets, or mcc account setup./ai-job-scoutFind open AI engineering jobs that fit a candidate, verify location and apply links, and assess each employer's product. Use for one-off shortlists or a job alert's research step. Don't use for résumé writing, job applications, or company news./appstore-assetsGenerate App Store screenshots, header/search images and looping videos for iPhone, iPad, Mac from code or a landing page, or re-render a set. Use when preparing a submission. Don't use for App Previews, ASO, review audits, icons, Google Play.Other plugins' skills for the same job