Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

CodeQL CLI

$ codeql Official Low Risk
GitHub · Files & Search · GitHub CodeQL Terms (Free for OSS) · macos / linux / windows

GitHub's official CodeQL CLI compiles codebases into relational AST/dataflow databases (database create) and runs QL security or structural queries (database analyze, query run). Findings export cleanly as SARIF JSON (--format=sarif-latest) or decoded JSON (bqrs decode --format=json).

FCRS-1.0 Score
86 /100
Good
Medium Confidence
Zero-Friction Install
brew install codeql
CLI vs MCP Decision CLI Preferred vs MCP

Local codeql database create and analyze --format=sarif-latest run heavy multi-minute static analysis directly on local builds.

Agent-Readiness Checklist

✓ JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 21 / 25

Outputs structured SARIF JSON (--format=sarif-latest) and bqrs decode --format=json headlessly, though multi-step DB creation and query packs add workflow complexity.

  • Supports --format=sarif-latest, bqrs decode --format=json, --threads, and --ram
  • Requires building a database before querying
Trust & Safety 21 / 25

Local analysis does not mutate source files (database create writes to an isolated DB directory); github upload-results requires explicit invocation and GITHUB_TOKEN.

  • Source tree remains untouched during DB creation and analysis
  • --overwrite deletes and replaces an existing DB directory
Setup & Portability 11 / 15

Large release bundle with embedded JVM via brew install codeql or GitHub releases; compiled languages (C/C++/Java/Go) require replicating full build commands.

  • Heavy binary distribution + build-tracer requirement for compiled languages
Utility & Efficiency 14 / 15

Unmatched interprocedural taint-tracking and semantic dataflow analysis far beyond regex or single-file AST tools.

  • Whole-program call-graph and dataflow queries
Maintenance & Lineage 10 / 10

Official GitHub security analysis engine with frequent releases and curated standard query packs.

  • Official GitHub product (github/codeql)
Docs & Verifiability 9 / 10

Extensive GitHub Docs CLI reference, QL language guide, and --help command tree.

  • Comprehensive official CodeQL CLI reference

Security, Auth & Guardrails

Auth Modes
No Auth Env API Key
Credential Storage

No credentials needed for local analysis; codeql github upload-results uses GITHUB_TOKEN or --github-auth-stdin.

Side Effects
Read-Only Local Write Remote Write
Cost & Quotas

Free for OSI open-source repos and academic research; commercial private-repo automation requires GitHub Advanced Security.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# CodeQL CLI Agent Rules
- Always export analysis with `--format=sarif-latest` or `bqrs decode --format=json` instead of parsing terminal tables.
- Check CodeQL licensing before running automated CI scans on private commercial repositories; avoid `--overwrite` unless rebuilding a stale DB.

Agent-Ready Command Recipes

Safe Read-Only Queries

Analyze CodeQL database and export SARIF JSON
codeql database analyze ./codeql-db --format=sarif-latest --output=results.sarif codeql/javascript-queries

Runs a standard CodeQL query pack against ./codeql-db and writes JSON-structured SARIF results.

Decode BQRS query results to JSON
codeql bqrs decode --format=json --output=results.json -- results.bqrs

Converts binary .bqrs results from codeql query run into structured JSON.

Controlled Writes & Previews

Build a local CodeQL database for Python
codeql database create ./codeql-db --language=python --source-root=.

Creates a local relational AST/dataflow database in ./codeql-db without modifying source files.

Strengths for Agents

  • + Full interprocedural AST and taint-flow analysis exported in standard SARIF JSON.
  • + bqrs decode --format=json turns custom QL queries into clean JSON payloads.

Caveats & Pitfalls

  • ! Commercial automation on closed-source repositories requires a GitHub Advanced Security license.
  • ! Database creation for compiled languages is slow and requires a clean build command (--command).

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI