ScriptAudit reads package scripts and local command docs, then produces a deterministic safety map so developers and coding agents know which commands are reasonable to run.
It is local-first: it scans files, classifies command strings, and writes reports. It never executes discovered target scripts.
npm install
npm run buildUse the local CLI during development:
node dist/cli.js scan . --out docs/SCRIPTS.mdAfter package installation, the binary is:
scriptaudit scan . --out docs/SCRIPTS.mdscriptaudit scan . --out docs/SCRIPTS.md
scriptaudit scan examples/fixtures/risky --format json --fail-on dangerous
scriptaudit init --preset oss-cliThe scan root must exist and be a directory. Invalid roots fail with a nonzero exit and a path-specific diagnostic instead of producing an empty audit. An existing empty directory is valid and produces a successful report with zero commands.
For a fixture-backed walkthrough, see docs/tutorials/audit-agent-cli-scripts.md. It scans a small agent-CLI example and shows how config can mark dry packaging as safe while blocking deployment commands.
package.jsonscripts across the repository.pnpm-workspace.yamlworkspace hints.- Makefile targets.
- Markdown shell blocks fenced with backticks or tildes and labelled
bash,sh,shell,console, orzsh(unlabelled fences are also scanned). Shell lines ending in\are joined before classification, and commands may begin with standard environment assignments such asCI=1 npm test. Each independently executable command must otherwise begin with a supported command or an optional$prompt. Supported commands include package and task runners, Node and shell entry points, plus risk-relevant network, container, version-control, destructive, permission, deploy, and publish tools such ascurl,docker,git,rm,sudo, andvercel. - Justfile recipes and Taskfile
cmdsentries written as scalar commands (- npm test) or inline mappings (- cmd: npm test).
Make discovery recognizes ordinary named targets, including rules that list multiple targets; each target is reported at the shared rule location with the same recipe. Pattern and special dot-prefixed targets are intentionally skipped. Justfile discovery recognizes named recipes with optional parameters and defaults. It ignores settings and assignments, and reports the recipe name and indented command body without expanding parameter values.
Markdown blocks labelled with other languages are deliberately ignored. Prose, comments, command output, continuations that do not start with a supported command, and commands embedded later in a line are not treated as independently executable commands.
safe: low-risk local verification such as tests, checks, builds, and smoke commands.caution: commands with possible local side effects, generated artifacts, containers, env-file references, or network-capable tools.dangerous: recursive or forcedrmcleanup, deploy, publish, privilege/ownership/permission changes, or policy-blocked commands. Destructive cleanup, deploy, and publish evidence takes precedence when a compound command also runs tests, checks, builds, or smoke validation. An explicit matching configrulesrisk remains the final override.unknown: commands without enough evidence to recommend confidently.
Each report includes evidence, detected tools, side-effect hints, network hints, and a recommended verification sequence.
Create scriptaudit.config.json with:
{
"knownSafe": ["publish:dry"],
"blocked": ["deploy"],
"rules": [
{
"match": "clean",
"risk": "caution",
"reason": "Cleanup deletes generated files."
}
]
}Config matching is intentionally simple and deterministic: a pattern matches a command id, script name, or command string.
An explicitly supplied --config path must exist. Config files are validated before scanning: knownSafe and blocked must be string arrays, while each rules entry requires a string match and may include a risk of safe, caution, dangerous, or unknown plus a string reason. Invalid files fail with the config path and precise field name.
ScriptAudit is a static heuristic tool, not a shell sandbox. It does not prove that a command is safe, and it does not replace maintainer judgment. Treat reports as a review appendix before running commands in an unfamiliar repo.
Discovery is fail-closed for invalid command sources. Malformed package.json or Taskfile YAML and non-string package.json script values stop the scan with a nonzero exit and a path-specific diagnostic; they are never treated as a clean zero-command audit.
- Run
scriptaudit scan . --out docs/SCRIPTS.md. - Read the recommended sequence first.
- Run
safeverification commands before broader checks. - Ask for human approval before running
dangerouscommands. - Keep generated reports in review artifacts when command choice matters.
npm test
npm run check
npm run build
npm run smoke
bash scripts/validate.shUse docs/release-readiness.md before opening release PRs or tagging a release. Version tags publish one npm tarball with trusted publishing and provenance, then attach that same tarball to the GitHub release. Pull requests that change release files dry-run publication of the packed artifact.
MIT