Js security audit

From c0x12c/ai-toolkit · View interactive version

Js security audit is an AI agent skill from the GitHub repository c0x12c/ai-toolkit. Audit JS/TS projects against NPM Security Guidelines covering project setup, dependency hygiene, CI/CD pipeline, Dependabot, and incident response. Use when reviewing package.json or lockfiles, adding or upgrading npm dependencies, setting up CI security gates, hardening a new repo, or responding to

How to use this skill

Skill file

JS Security Audit

Run a 5-area security audit on a JS/TS project (npm, yarn, or pnpm). Produces a pass/fail report per area with file:line references.

When to Use

Process

See audit-checklist.md for the full MUST/SHOULD/SHOULDN'T list.

See eslint-security.md for the SAST ESLint template and rules table.

See incident-playbook.md for the 5-step compromised-dependency response.

See package-manager.md for npm/yarn/pnpm command equivalents and tooling.

Detect package manager first by checking which lockfile exists: package-lock.json (npm), yarn.lock (yarn), pnpm-lock.yaml (pnpm). Use the matching commands from package-manager.md.

1. Project Setup

Check .npmrc, lockfile presence, version pinning, .gitignore, scoped packages.

2. Dependency Hygiene

Run audit, scan lockfile diff for unexpected packages, check for latest tags and trivial deps.

3. CI/CD Pipeline

Verify npm ci over npm install, --ignore-scripts with selective rebuild allowlist, audit gate, lockfile-lint, SHA-pinned actions, SBOM, ESLint security config.

4. Dependabot

Check .github/dependabot.yml, alert routing, P1 SLA on critical/high, grouping config.

5. Incident Response Readiness

Verify the team has a documented playbook, IOC monitoring, credential-rotation runbook.

Interaction Style

Rules

Gotchas

Recommended Permission Allowlist

The skill needs Bash to run npm audit and friends. To avoid prompts on every audit, add these to your ~/.claude/settings.json (or project .claude/settings.json):

{
  "permissions": {
    "allow": [
      "Bash(npm audit:*)",
      "Bash(npm outdated:*)",
      "Bash(npm explain:*)",
      "Bash(npm list:*)",
      "Bash(npm view:*)",
      "Bash(yarn npm audit:*)",
      "Bash(yarn outdated:*)",
      "Bash(yarn why:*)",
      "Bash(pnpm audit:*)",
      "Bash(pnpm outdated:*)",
      "Bash(pnpm why:*)",
      "Bash(npx lockfile-lint:*)",
      "Bash(npx npq:*)"
    ]
  }
}

This keeps the audit commands silent while leaving everything else (write operations, deletes, etc.) gated behind a prompt.

Output

Produces an audit report:

## JS Security Audit: {repo}

### Overall: Pass | Fail

| Area               | Status   | Critical | Warnings | Info |
|--------------------|----------|----------|----------|------|
| Project Setup      | Pass     | 0        | 1        | 0    |
| Dependency Hygiene | Fail     | 1        | 0        | 0    |
| CI/CD Pipeline     | Pass     | 0        | 2        | 1    |
| Dependabot         | Warning  | 0        | 1        | 0    |
| Incident Response  | Info     | 0        | 0        | 1    |

### Critical Findings
- **[Dependency Hygiene]** `lodash` pinned to `latest` in package.json:24
  - Fix: Replace with exact version `"lodash": "4.17.21"`
  - Reason: `latest` resolves at install time, defeating lockfile guarantees

### Warnings
- **[Project Setup]** `.npmrc` missing `ignore-scripts=true`
  - File: `.npmrc:1`
  - Fix: Add `ignore-scripts=true` and use `npm rebuild` for allowlisted packages

### Remediation Priority
1. Fix critical findings before merging
2. Address warnings in next sprint
3. Info items as time permits
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.