Skip to content

CLI Runner

Swarm QA includes a CLI interface for running scans from the terminal — designed for CI/CD pipeline integration. The CLI uses HTTP-based checks (not a full browser) for speed and portability.

Commands

CommandPresetDescription
npm run swarm:runStandard Scan6 agents, 180s timeout, 20 pages
npm run swarm:quickQuick SmokeLink Patrol + Smoke Flow, 60s, 5 pages
npm run swarm:deepDeep AuditAll 8 agents, 420s timeout, 50 pages

Flags

FlagDescriptionDefault
--target <url>Target URL to scanRequired
--jsonOutput results as JSON to stdoutOff (human-readable)
--out <path>Write results to a file instead of stdoutstdout
--threshold <n>Minimum acceptable score (affects exit code)0
--agents <list>Comma-separated agent names to enablePreset default

Exit Codes

CodeMeaning
0Scan completed, score meets or exceeds threshold
1Scan completed, score below threshold or critical findings detected
2Scan failed (network error, auth failure, invalid target)

INFO

Exit code 1 on any fix-now finding makes the CLI a natural quality gate. A pipeline step using npm run swarm:quick -- --target $STAGING_URL fails the build if critical issues are found.

JSON Output Format

When --json is passed, the output follows this structure:

json
{
  "target": "https://staging.example.com",
  "score": 81,
  "duration": "2m 12s",
  "agents": {
    "link-patrol": { "findings": 3, "duration": "18s" },
    "smoke-flow": { "findings": 1, "duration": "12s" }
  },
  "findings": [
    {
      "agent": "link-patrol",
      "severity": "high",
      "action": "fix-now",
      "url": "https://staging.example.com/about",
      "message": "Broken link: /team returns 404",
      "evidence": "HTTP 404 on GET /team"
    }
  ]
}

Score Algorithm

The CLI uses the same scoring formula as the GUI:

score = 100 - (critical x 15) - (high x 8) - (medium x 3) - (low x 1)

Only first-party findings count. The score is clamped to a minimum of 0.

CI Pipeline Example

yaml
# GitLab CI
swarm-qa:
  stage: test
  script:
    - npm run swarm:quick -- --target $STAGING_URL --threshold 70 --json --out swarm-results.json
  artifacts:
    paths: [swarm-results.json]
    when: always

TIP

Use --json --out to save results as a build artifact. This works with GitLab CI, GitHub Actions, Jenkins, and any CI system that supports npm scripts.

WARNING

The CLI runner uses HTTP-based checks, not a full browser. Agents that require JavaScript rendering (Form Fuzzer, Visual Regression) are skipped in CLI mode. Use the GUI or scheduled scans for full coverage.

Local-first QA orchestration.