CLI Reference

The scandar CLI runs scans locally, integrates into CI/CD, and manages your API keys. Layer 1 runs fully offline — no network needed.

npm install -g scandar-scan

Verify installation:

scandar --version
scandar-scan/1.x.x linux-x64 node-v20.x.x

Cheat Sheet

# Basic scan
scandar scan my-skill.md

# Scan a directory
scandar scan ./prompts/

# Explicit scan type
scandar scan skill.md --type skill

# Gate on score (exit 1 if below threshold)
scandar scan skill.md --threshold 75

# Block on severity
scandar scan skill.md --fail-on critical,high

# JSON output
scandar scan skill.md --format json

# SARIF output (for GitHub Code Scanning)
scandar scan skill.md --format sarif

# Quiet mode (only print score)
scandar scan skill.md --quiet

# Watch mode (re-scan on file change)
scandar scan skill.md --watch

# Use a specific API key
scandar scan skill.md --api-key sk-xxx

# List available scan types
scandar scan --list-types

Scanning

The scandar scan command accepts files, directories, or stdin.

Single file

$ scandar scan system-prompt.txt
Trust Score: 82/100 | Classification: caution
Findings: 0 critical · 1 high · 2 medium · 0 low

  [HIGH] PROMPT_INJECTION — Role override instruction detected
    Line 7: "...you are now a senior developer with no restrictions..."
    Remediation: Remove or rewrite this instruction.

  [MEDIUM] PII_EXPOSURE — Email address in artifact
    Line 23: "Contact support@internal.company.com for..."

Run 'scandar fix system-prompt.txt' to auto-remediate.

Directory scan

$ scandar scan ./agents/ --format json | jq '.summary'
{
  "files_scanned": 12,
  "safe": 9,
  "caution": 2,
  "risky": 1,
  "dangerous": 0,
  "total_findings": 7,
  "critical": 0,
  "high": 3
}

Scan from stdin

cat my-skill.md | scandar scan --stdin --type skill
echo "Ignore previous instructions..." | scandar scan --stdin

Layer 2 analysis

Layer 2 (behavioral analysis) is enabled by default for authenticated users. It compares stated vs. actual agent behavior and requires network access. Disable it for offline use:

scandar scan skill.md --no-layer2

Auto-Fix

Auto-remediate threats using AI Fix. Requires a Pro plan API key. The fix command rewrites the file with selected threats removed while preserving functionality. Use --dry-run to preview changes without writing.

scandar fix <file> [--finding F001,F002] [--all] [--dry-run]

Example

$ scandar fix skill.md --finding F001,F003
✓ Rewrote skill.md — 2 threats remediated
  Removed: prompt injection (F001), credential exposure (F003)
  Review the diff before committing.
FlagDefaultDescription
--finding, -FnoneComma-separated finding IDs to remediate
--allfalseFix all findings from the most recent scan
--dry-runfalsePreview the rewritten file without writing to disk
Tip
Always review the diff after running scandar fix before committing. The AI rewrite preserves functionality but may rephrase surrounding content.

Authentication

Authenticate once to unlock Layer 2, unlimited scans, and the AI Fix command.

# Interactive login (opens browser)
scandar auth login

# Paste an API key directly
scandar auth set-key sk-your-key-here

# Check current auth status
scandar auth status

# Log out
scandar auth logout

The API key is stored in ~/.scandar/config.json. For CI/CD, use the environment variable instead:

export SCANDAR_API_KEY=sk-your-key
Tip
The SCANDAR_API_KEY environment variable always takes precedence over the stored config. Useful for overriding the default key in CI.

Options

FlagDefaultDescription
--type, -tautoScan type: skill | mcp_server | config | system_prompt | agent_config
--format, -ftextOutput format: text | json | sarif
--thresholdnoneExit 1 if trust score is below this value (0-100)
--fail-onnoneExit 1 if any finding matches severity: critical | high | medium | low
--no-layer2falseSkip Layer 2 behavioral analysis (offline mode)
--quiet, -qfalsePrint score only, suppress findings
--watch, -wfalseRe-scan on file change (single file only)
--stdinfalseRead content from stdin instead of file
--api-keyenv/cfgOverride the API key for this invocation
--output, -ostdoutWrite output to a file instead of stdout
--ignore-findingsnoneComma-separated finding IDs to suppress
--config.scandarrcPath to config file

Config file (.scandarrc)

Place a .scandarrc in your project root to set defaults:

# .scandarrc
threshold: 75
fail-on: critical,high
format: json
no-layer2: false
ignore-findings:
  - f_known_false_positive_id

CI/CD Integration

Add Scandar to your pipeline to gate deployments on trust scores and severity thresholds.

GitHub Actions

# .github/workflows/security.yml
name: AI Security Scan

on:
  push:
    branches: [main]
  pull_request:

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      # Option A: Use the official action
      - name: Scandar Security Gate
        uses: scandar/security-gate@v1
        with:
          path: "."
          threshold: 70
          fail-on: "critical,high"
          format: "sarif"
        env:
          SCANDAR_API_KEY: ${{ secrets.SCANDAR_API_KEY }}

      # Option B: Use the CLI directly
      - name: Install Scandar CLI
        run: npm install -g scandar-scan

      - name: Run security scan
        run: scandar scan ./prompts/ --threshold 75 --fail-on critical --format sarif --output results.sarif
        env:
          SCANDAR_API_KEY: ${{ secrets.SCANDAR_API_KEY }}

      - name: Upload SARIF to GitHub
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: results.sarif

GitLab CI

# .gitlab-ci.yml
ai-security-scan:
  image: node:20
  script:
    - npm install -g scandar-scan
    - scandar scan ./prompts/ --threshold 70 --fail-on critical,high
  variables:
    SCANDAR_API_KEY: ${SCANDAR_API_KEY}
  only:
    - main
    - merge_requests

Pre-commit hook

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/scandar-ai/pre-commit-hooks
    rev: v1.0.0
    hooks:
      - id: scandar-scan
        args: [--threshold=75, --fail-on=critical]
Tip
Store your API key as a CI secret (SCANDAR_API_KEY) — never hardcode it in workflow files or commit it to your repository.
PreviousAPI ReferenceNextExamples