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.
| Flag | Default | Description |
|---|---|---|
| --finding, -F | none | Comma-separated finding IDs to remediate |
| --all | false | Fix all findings from the most recent scan |
| --dry-run | false | Preview the rewritten file without writing to disk |
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
SCANDAR_API_KEY environment variable always takes precedence over the stored config. Useful for overriding the default key in CI.Options
| Flag | Default | Description |
|---|---|---|
| --type, -t | auto | Scan type: skill | mcp_server | config | system_prompt | agent_config |
| --format, -f | text | Output format: text | json | sarif |
| --threshold | none | Exit 1 if trust score is below this value (0-100) |
| --fail-on | none | Exit 1 if any finding matches severity: critical | high | medium | low |
| --no-layer2 | false | Skip Layer 2 behavioral analysis (offline mode) |
| --quiet, -q | false | Print score only, suppress findings |
| --watch, -w | false | Re-scan on file change (single file only) |
| --stdin | false | Read content from stdin instead of file |
| --api-key | env/cfg | Override the API key for this invocation |
| --output, -o | stdout | Write output to a file instead of stdout |
| --ignore-findings | none | Comma-separated finding IDs to suppress |
| --config | .scandarrc | Path 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.sarifGitLab 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_requestsPre-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]SCANDAR_API_KEY) — never hardcode it in workflow files or commit it to your repository.