| name | socket-setup |
|---|---|
| description | Set up Socket - prompt for API key, install the CLI, authenticate, configure policies and tokens, set up CI/CD for firewall or patch modes across GitHub, GitLab, Bitbucket, and other systems. |
- User wants to get started with Socket
- User needs to install/configure the Socket CLI
- User wants to authenticate with Socket
- User wants to set up Socket Firewall
- User wants to set up socket-patch for automated patching
- User wants to add Socket to CI/CD pipelines
- User wants to configure Socket policies (
socket.yml) - User wants to set up API tokens for CI or local development
- User is having trouble authenticating
- User wants to install Socket tools globally for local development
- User wants to integrate Socket into Dockerfiles
Ask each tool for its version. A command not found error means the tool is not installed:
node --version
socket --version
sfw --version
socket-patch --versionDetect the package manager from the lock file in the project root - the command prints only the files that exist:
ls -d package-lock.json pnpm-lock.yaml yarn.lock bun.lock bun.lockb 2>/dev/null || truepackage-lock.json means npm, pnpm-lock.yaml means pnpm, yarn.lock means yarn, and bun.lock or bun.lockb means bun. With no lock file, ask the user which package manager the project uses.
Handle results:
- If
node --versionfails: prompt the user to install Node.js. Suggest:- nvm (recommended):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bashthennvm install 20 - Homebrew (macOS):
brew install node - Official installer: https://nodejs.org/
- nvm (recommended):
- If
node --versionreports below v18: warn that Node.js 18+ is required and suggest upgrading - If
socket --versionreports below 1.0.0: warn that the Socket CLI is below 1.x and prompt to update withnpm install -g socket@latest - If
socket --versionfails: proceed to Step 3 (Install the CLI)
Ask the user whether they have or want to create a Socket account. There are three tiers:
- No account (public token): No sign-up required. The Socket CLI supports a built-in public token that provides limited access to CLI features including
socket fix,socket scan,sfw, andsocket-patch apply. Rate limits and feature restrictions apply compared to a full account, but basic vulnerability scanning and fixing work out of the box. Dashboard access, organization management, and policy configuration are NOT available without an account. - Free account: Create one at https://socket.dev. Removes public-token rate limits, enables full dashboard access and organization features. All CLI features are available.
- Sign up / sign in: https://socket.dev/auth/login
- Token page: https://socket.dev/dashboard/org/{ORG}/settings/integrations/api-tokens
- Enterprise account: All free account features plus reachability analysis (
socket scan reach), policy configuration (socket.yml), and organization-level management.
Store the tier choice for subsequent steps.
-
Prerequisites: Node.js 18+ (verified in Step 1)
-
npm install -g socket -
After install, confirm the version is >= 1.x:
socket --version
-
If the version is still below 1.x after install, error and suggest
npm install -g socket@latest -
PATH troubleshooting: if
socketis not found, check that the npm global bin directory is inPATH. Print the global install prefix withnpm prefix -g; the bin directory is<prefix>/binon macOS and Linux, and the prefix itself on Windows
If the user chose no-account in Step 2, configure the public demo token directly:
pnpm dlx socket config set apiToken sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api --no-banner --no-spinner
pnpm dlx socket config set defaultOrg SocketDemo --no-banner --no-spinnerThis configures the CLI with a limited public token that provides access to features like socket fix, socket package score, sfw, and socket-patch with rate limits. No user interaction is needed - run this in the background as part of setup. Note: The demo token cannot create scans (socket scan create requires a free account).
Verify it worked:
socket --versionThe CLI is now functional. Skip socket organization list (no org exists for public-token users). Inform the user that they can create a free account at https://socket.dev later to remove rate limits, enable scanning, and access the dashboard.
- Interactive:
socket login - Manual token:
SOCKET_CLI_API_TOKENenv var - Verify:
socket organization list - Authentication is required for full-rate scanning (
socket scan create) andsocket fix, dashboard access, and organization management
Ask the user which features to set up. Annotate each with its tier requirement:
- Firewall (
sfw) - works with public token - Patches (
socket-patch apply) - works with public token - Scanning (
socket scan create) - works with public token (rate-limited); full account removes limits - Fix (
socket fix) - works with public token (rate-limited); full account removes limits - Global Tools - works with public token
- Dockerfile Integration - works with public token
- Policies (
socket.yml) - enterprise only
All core CLI features work with the public token set up in Step 4. If the user hits rate limits or needs dashboard access, suggest creating a free account at https://socket.dev.
Route to the appropriate section(s) below.
Ask the user if they want to install Socket tools globally (for local development) or just for CI.
If global, install all tools via npm:
npm install -g socket
npm install -g sfw
npm install -g @socketsecurity/socket-patchAfter installing, verify each tool is available:
socket --version
sfw --version
socket-patch --versionConfirm all three print a version rather than command not found.
If any tool fails to install, check PATH and retry. npm prefix -g prints the global install prefix; the bin directory is <prefix>/bin on macOS and Linux, and the prefix itself on Windows.
List the CI config files that exist in the project root - the command prints only the ones that are present:
ls -d .github/workflows .gitlab-ci.yml bitbucket-pipelines.yml Jenkinsfile .circleci/config.yml .travis.yml azure-pipelines.yml 2>/dev/null || trueThen identify the SCM and map the results:
- Run
git remote -vto detect the SCM:- github.com → GitHub
- gitlab.com or self-hosted GitLab → GitLab
- bitbucket.org → Bitbucket
- Other / not a git repo → Generic
- Based on SCM, infer the likely CI system, but also check for:
- .github/workflows/ → GitHub Actions
- .gitlab-ci.yml → GitLab CI
- bitbucket-pipelines.yml → Bitbucket Pipelines
- Jenkinsfile → Jenkins
- .circleci/config.yml → CircleCI
- .travis.yml → Travis CI
- azure-pipelines.yml → Azure Pipelines
- None found → Generic / manual
| Package Manager | Install sfw |
|---|---|
| npm | npm install -g sfw |
| pnpm | pnpm add -g sfw |
| bun | bun add -g sfw |
| Standalone | curl -fsSL https://socket.dev/download/sfw/latest/{platform} -o /usr/local/bin/sfw && chmod +x /usr/local/bin/sfw |
Replace {platform} with linux-x64, darwin-arm64, etc. as appropriate.
All Socket tools (sfw, socket-patch, socket CLI) are npm packages. The standalone curl method remains available for CI environments that may not have npm.
- Use SocketDev/action@v1
- Free tier: mode: firewall-free (no socket-token needed)
- Enterprise: mode: firewall, socket-token: ${{ secrets.SOCKET_API_KEY }}
- Insert after actions/checkout, before install steps
- Prefix install commands with sfw (sfw npm install, sfw pip install, etc.)
- Guide user to set up GitHub secret if enterprise
- If GitHub: also offer to install the Socket Security GitHub App (github.com/apps/socket-security) for automatic PR scanning
-
Add a
before_scriptor dedicated stage to installsfw -
Install via npm:
npm install -g sfw -
Or install standalone binary:
curl -fsSL https://socket.dev/download/sfw/latest/linux-x64 -o /usr/local/bin/sfw && chmod +x /usr/local/bin/sfw -
Prefix install commands with sfw (
sfw npm install,sfw pip install, etc.) -
Enterprise: set
SOCKET_CLI_API_TOKENas CI/CD variable in GitLab settings
-
Add pipe step to install
sfwbinary:curl -fsSL https://socket.dev/download/sfw/latest/linux-x64 -o /usr/local/bin/sfw && chmod +x /usr/local/bin/sfw -
Prefix install commands with sfw
-
Enterprise: set
SOCKET_CLI_API_TOKENas repository variable
-
Download
sfwbinary:# Linux x64 curl -fsSL https://socket.dev/download/sfw/latest/linux-x64 -o /usr/local/bin/sfw && chmod +x /usr/local/bin/sfw # macOS arm64 curl -fsSL https://socket.dev/download/sfw/latest/darwin-arm64 -o /usr/local/bin/sfw && chmod +x /usr/local/bin/sfw
-
Or install via npm:
npm install -g sfw -
Prefix install commands with sfw
-
Set
SOCKET_CLI_API_TOKENas env var for enterprise
npm install -g sfw(or standalone binary as above)- Usage:
sfw npm install,sfw pip install, etc.
Set up automated patching so socket-patch apply runs after every dependency install. For one-time manual patching, use the /socket-dep-patch skill instead.
Identify the project's CI/CD system - the command prints only the config files that are present:
ls -d .github/workflows .gitlab-ci.yml bitbucket-pipelines.yml Jenkinsfile .circleci/config.yml .travis.yml azure-pipelines.yml 2>/dev/null || trueBefore configuring automation, scan the project to find ALL places where dependencies are installed and builds happen:
| Location | What to Look For |
|---|---|
package.json scripts |
install, postinstall, build, prebuild |
| CI configs (all formats) | install steps, build steps |
Makefile / Justfile |
install and build targets |
Dockerfile / docker-compose |
RUN install, RUN build layers |
Shell scripts (*.sh) |
install/build commands |
pyproject.toml / setup.py |
build system config |
Cargo.toml |
build scripts |
For each location, record the file path, the install command, and where to insert socket-patch scan and socket-patch apply (after install, before build).
Present findings to the user before making changes.
Use the appropriate command to run socket-patch based on the project's package manager:
| Package Manager | Run socket-patch |
|---|---|
| npm | npx @socketsecurity/socket-patch scan then npx @socketsecurity/socket-patch apply |
| pnpm | pnpm dlx @socketsecurity/socket-patch scan then pnpm dlx @socketsecurity/socket-patch apply |
| yarn | npx @socketsecurity/socket-patch scan then npx @socketsecurity/socket-patch apply |
| bun | bunx @socketsecurity/socket-patch scan then bunx @socketsecurity/socket-patch apply |
| deno | deno run npm:@socketsecurity/socket-patch scan then deno run npm:@socketsecurity/socket-patch apply |
| Python | pipx run socket-patch scan && pipx run socket-patch apply (if pipx available), else pip install socket-patch && socket-patch scan && socket-patch apply |
| Standalone | curl -fsSL https://raw.githubusercontent.com/SocketDev/socket-patch/main/install.sh | sh then socket-patch scan && socket-patch apply |
| GitHub Actions | SocketDev/action@v1 with mode: patch (preferred - handles scan+apply automatically) |
Use the runner that matches the detected package manager in the sections below: npx for npm and yarn, pnpm dlx for pnpm, bunx for bun.
Use SocketDev/action@v1 with mode: patch:
- uses: SocketDev/action@v1
with:
mode: patch
# patch-ecosystems: npm,pypi (optional: limit to specific ecosystems)
# patch-dry-run: false (optional: dry run mode)
Place after actions/checkout, before install steps. No socket-token is needed for patch mode.
Add a step to install socket-patch and apply patches after dependency install. Use the appropriate package manager runner (see reference table above):
before_script:
- curl -fsSL https://raw.githubusercontent.com/SocketDev/socket-patch/main/install.sh | sh
- npm install
- socket-patch scan
- socket-patch applyAdd a step to install socket-patch and apply patches. Use the appropriate package manager runner (see reference table above):
script:
- curl -fsSL https://raw.githubusercontent.com/SocketDev/socket-patch/main/install.sh | sh
- npm install
- socket-patch scan
- socket-patch applyGeneric pattern for any CI system:
- Install
socket-patchvia curl, npm, or the appropriate package manager runner (see reference table above) - Run your normal dependency install step
- Run
socket-patch scanto discover available patches - Run
socket-patch applyafter scan, before build
Run socket-patch setup to add a postinstall hook to package.json:
socket-patch setupThis auto-adds a postinstall hook to your package.json scripts that runs socket-patch scan && socket-patch apply every time npm install runs.
Add a RUN socket-patch apply layer after the install layer. Use the appropriate runner for the project's package manager (e.g. pnpm dlx for pnpm, bunx for bun):
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
RUN pnpm dlx @socketsecurity/socket-patch scan
RUN pnpm dlx @socketsecurity/socket-patch apply
COPY . .
RUN npm run buildAdd a patch target that runs after install. Adapt commands to match the project's package manager:
install:
npm ci
socket-patch scan
socket-patch apply
build: install
npm run buildIf the project uses an unusual build system, use the appropriate package manager runner (see reference table above):
- Interpreted projects (Python, Ruby): add
socket-patch scan && socket-patch applyafterpip install/bundle install - Compiled projects (Rust, Go, Java): add
socket-patch scan && socket-patch applyafter dependency fetch, before compile - Containers: add
RUN socket-patch scanandRUN socket-patch applylayers after the install layer
Detect Dockerfiles and edit them directly to integrate Socket's firewall and/or patch tools.
Find every Dockerfile in the project:
find . -type f \( -name 'Dockerfile' -o -name 'Dockerfile.*' -o -name '*.Dockerfile' -o -name 'Containerfile' \) -not -path '*/node_modules/*' -not -path '*/.git/*'Read each file that the command lists and record, per file:
- Each
RUNline that installs dependencies -npm ci,npm install,yarn install,pnpm install,bun install,pip install,bundle install,cargo build,go mod download- along with its line number and ecosystem - Whether the file already mentions
sfw - Whether the file already mentions
socket-patch
If no Dockerfiles are found or none contain dependency install steps, skip this section.
For each Dockerfile that has install steps, read the file and apply edits directly.
Determine the mode based on what the user chose in Step 5 (Firewall, Patches, or both).
For each install line recorded in Step 1:
- Firewall mode: Insert
RUN npm install -g sfwon a new line before the install step. Prefix the install command withsfw(e.g.,RUN npm ci→RUN sfw npm ci). - Patch mode: Insert
RUN pnpm dlx @socketsecurity/socket-patch scanandRUN pnpm dlx @socketsecurity/socket-patch applyon new lines after the install step, before any build or COPY steps. - Both modes: Apply both sets of changes (sfw install + prefix before, socket-patch after).
Rules:
- Only modify stages that have dependency install steps (multi-stage build awareness - check for
FROMlines to identify stage boundaries) - Skip lines that already contain
sfworsocket-patchto ensure idempotency - Use the appropriate package manager runner for socket-patch (
npxfor npm and yarn,pnpm dlxfor pnpm,bunxfor bun - see Package Manager Reference table)
Before writing the modified Dockerfile, present the proposed changes to the user and explain each edit:
What each mode inserts, with a before/after Dockerfile example
- Firewall: inserts
RUN npm install -g sfwbefore the install step, prefixes the install command withsfw - Patches: inserts
RUN pnpm dlx @socketsecurity/socket-patch scanandRUN pnpm dlx @socketsecurity/socket-patch applyafter the install step, before build/copy steps
Only write the file after the user approves.
Example - a Dockerfile before and after (both modes):
Before:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run buildAfter:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install -g sfw
RUN sfw npm ci
RUN pnpm dlx @socketsecurity/socket-patch scan
RUN pnpm dlx @socketsecurity/socket-patch apply
COPY . .
RUN npm run buildEnterprise only - free tier users cannot configure policies. Skip this section if on the free tier.
Configure Socket policies to control which issues are flagged during scans and CI checks.
Create socket.yml in the repository root with version: 2 and these default issue rules, then adjust the values with the user:
The default socket.yml issue rules and what error/warn/ignore mean
version: 2
issueRules:
# CVE severity thresholds
criticalCVE: error # Block on critical CVEs
highCVE: warn # Warn on high CVEs
mediumCVE: ignore # Ignore medium CVEs
# Supply-chain alerts
installScripts: error # Block packages with install scripts
networkAccess: warn # Warn on unexpected network access
shellAccess: warn # Warn on shell execution
filesystemAccess: ignore # Ignore filesystem access alerts
envVarsAccess: warn # Warn on environment variable reads
obfuscatedCode: error # Block obfuscated code
# Malware
malware: error # Always block malware
# License compliance
gplLicense: warn # Warn on GPL licenses
noLicense: warn # Warn on packages with no license
nonPermissiveLicense: warn # Warn on restrictive licenses
projectIgnorePaths:
- 'test/**'
- 'tests/**'
- 'examples/**'
- 'docs/**'
- '__fixtures__/**'
Issue rule values:
error- fail the check / block the PRwarn- report but don't failignore- suppress entirely
For enterprise customers, policies can also be managed via the Socket dashboard:
- Organization-level:
https://socket.dev/dashboard/org/{ORG}/settings/policies - Repository-level:
https://socket.dev/dashboard/org/{ORG}/repo/{REPO}/settings/policies
When multiple policies exist, they are applied in this order (highest priority first):
- Repository
socket.ymlin repo root - Organization-level dashboard policy
- Socket defaults
Repository-level settings override organization-level settings, which override defaults.
Different Socket features use different tokens. Set up the appropriate tokens for your use case.
| Token | Environment Variable | Used By | Required For |
|---|---|---|---|
| CLI API Token | SOCKET_CLI_API_TOKEN |
Socket CLI (socket commands), CI/CD |
Enterprise scans, socket fix, socket organization list |
| Security API Key | SOCKET_SECURITY_API_KEY |
Batch PURL API (api.socket.dev) |
Package inspection, license auditing |
| GitHub Action Token | socket-token (GitHub secret) |
SocketDev/action@v1 |
Enterprise firewall mode in GitHub Actions |
- Sign in to the Socket dashboard: https://socket.dev/auth/login
- Navigate to your organization's API tokens page:
https://socket.dev/dashboard/org/{ORG}/settings/integrations/api-tokens - Create a new token with the appropriate scope
- Copy the token value - it is only shown once
| CI System | How to Set Secrets |
|---|---|
| GitHub Actions | Repository Settings → Secrets and variables → Actions → New repository secret |
| GitLab CI | Settings → CI/CD → Variables → Add variable (masked, protected) |
| Bitbucket Pipelines | Repository settings → Repository variables |
| CircleCI | Project Settings → Environment Variables |
| Jenkins | Credentials → Add Credentials → Secret text |
| Azure Pipelines | Pipelines → Library → Variable groups |
For local development, authenticate using one of:
- Interactive login:
socket login(stores credentials in~/.socket/) - Environment variable: Set
SOCKET_CLI_API_TOKENin your shell profile or.env.local - Per-project: Add
SOCKET_SECURITY_API_KEYto.env.local(ensure.env.localis in.gitignore)
Never commit API tokens to version control. Use socket login locally and environment variables / secrets in CI.
socket: command not found: Ensure Node.js 18+ is installed, then runnpm install -g socket. Check that the npm global bin directory is inPATH-npm prefix -gprints the global prefix, and the bin directory is<prefix>/binon macOS and Linux, or the prefix itself on Windows.socket loginfails: Check network connectivity. If behind a proxy, ensureHTTPS_PROXYis set. Try settingSOCKET_CLI_API_TOKENdirectly as an environment variable instead.socket organization listreturns empty: The API token may lack organization access. Verify the token at https://socket.dev/dashboard and ensure it has the correct scopes.sfwnot intercepting installs: Ensuresfwis inPATHbefore the package manager. In CI, verify the install step runs before any dependency install commands.- GitHub Action fails with permission errors: Ensure the
socket-tokensecret is set correctly in the repository settings and the workflow hascontents: readpermission. - Socket CLI version < 1.x: Run
npm install -g socket@latestto update. Verify withsocket --version. - Dockerfile editing issues: Re-run the Dockerfile
findcommand from the Dockerfile Integration section to verify which files and lines need changes. Only edit stages with dependency install steps and skip lines that already containsfworsocket-patch.
- Never commit API tokens. Use
socket loginlocally, env vars in CI. - For users without an account, configure the public demo token with
pnpm dlx socket config set apiToken sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_apiandpnpm dlx socket config set defaultOrg SocketDemo. This gives limited access to CLI features likesocket fix,socket package score,sfw, andsocket-patchwith rate limits. The demo token cannot create scans -socket scan createrequires a free account at https://socket.dev. Always configure the demo token for no-account users during setup so the CLI is functional immediately. - For full-rate access, dashboard, and organization features, users need a free or enterprise account at https://socket.dev.
- Use
SocketDev/action@v1(correct casing) in GitHub workflow files. - For monorepos, use
patch-cwdto target specific directories. - After setup, use the
/socket-scanskill for a first audit and the/socket-inspectskill for package inspection. - For GitHub repos, consider also installing the Socket Security GitHub App for automatic PR scanning.
- Run
socket --version,sfw --version, andsocket-patch --versionat any time to verify tool installation status. - Run the Dockerfile
findcommand from the Dockerfile Integration section to locate all Dockerfiles before manual editing. - The generated
socket.ymlusesversion: 2- ensure this line is preserved when editing policies.