Configure and run CodeQL code scanning with GitHub Actions workflows, default or advanced setup, CodeQL CLI databases, SARIF uploads, custom query packs, monorepo categories, build modes, and alert triage. Use this skill when the user asks to create or customize codeql.yml, choose CodeQL setup, configure a language matrix, run codeql database create or database analyze, upload SARIF, troubleshoot CodeQL builds, or interpret code scanning alerts.
Set up, run, and troubleshoot CodeQL analysis through GitHub Actions or the CodeQL CLI, producing a working workflow, local commands, SARIF upload path, and alert triage guidance.
When to invoke
"Create a CodeQL workflow for this repository."
"Should we use default setup or advanced setup for code scanning?"
"Run CodeQL CLI locally and upload SARIF."
"Troubleshoot this CodeQL build-mode failure."
"Configure CodeQL for a monorepo with custom query packs."
Prerequisites and context
GitHub code scanning must be available for the repository.
Advanced setup uses .github/workflows/codeql.yml and may use .github/codeql/codeql-config.yml.
CLI uploads require GITHUB_TOKEN with security-events: write plus repository, ref, and commit metadata.
compiled; watch /p:EmitCompilerGeneratedFiles=true conflicts with .sqlproj or legacy projects.
Go
go
—
usually autobuilds through standard Go tooling.
Java/Kotlin
java-kotlin
java, kotlin
Kotlin no-build mode may need default setup disabled and re-enabled to switch to autobuild.
JavaScript/TypeScript
javascript-typescript
javascript, typescript
alternative identifiers still analyze both JS and TS.
Python
python
—
no build mode required.
Ruby
ruby
—
no build mode required.
Rust
rust
—
build mode can matter for extraction completeness.
Swift
swift
—
compiled; runner and build environment matter.
GitHub Actions
actions
—
analyzes workflow code.
GitHub Actions workflow
Choose setup type.
Default setup: enable in repository Settings → Advanced Security → CodeQL analysis. Best for fast onboarding; uses none build mode for most languages.
Advanced setup: commit .github/workflows/codeql.yml for full control over triggers, build modes, query suites, path filters, custom packs, and monorepos. Disable default setup before switching to advanced.
Configure triggers. Use push, pull_request, schedule, and merge_group when merge queues are enabled. paths-ignore controls whether the workflow runs, not which files are analyzed.
Set least-privilege permissions: security-events: write, contents: read, and actions: read for private repositories using codeql-action.
Use a matrix with fail-fast: false and one row per language/build-mode pair.
Initialize, build if needed, analyze, and set a unique category such as /language:${{ matrix.language }} or /language:${{ matrix.language }}/component:frontend.
Common suites are <language>-code-scanning.qls, <language>-security-extended.qls, and <language>-security-and-quality.qls. Use --command for compiled-language database creation. Use --verbosity=progress++ and --logdir=codeql-logs for local debug logs.
Alerts, logs, and limits
Topic
Guidance
Severity
Standard severity is Error, Warning, or Note; security severity is Critical, High, Medium, or Low from CVSS and takes display precedence.
PR alerts
Alerts appear as check annotations on changed lines; checks fail by default for error, critical, or high.
False positives
Dismiss only with a documented reason for audit history.
GitHub Copilot Autofix
Review generated fixes carefully before committing; no Copilot subscription is required for CodeQL alert suggestions in PRs.
Logs
Review lines of code in codebase, lines extracted, extraction errors/warnings, and debug logging from workflow reruns.
SARIF
Use --sarif-category to split results; SARIF uploads have a 10 MB file size limit.
Runners
Small codebases need about 8 GB RAM and 2 cores; medium 16 GB and 4–8 cores; large 64 GB and 8 cores. All need SSD storage with at least 14 GB free.
Troubleshooting
Problem
Resolution
Workflow not triggering
Verify on: event, branches, paths filters, and that the workflow exists on the target branch.
Resource not accessible
Add security-events: write and contents: read; add actions: read for private repos using codeql-action.
Autobuild failure
Switch to build-mode: manual and add explicit build commands between init and analyze.
No source code seen
Verify --source-root, language identifier, path config, and build command.
Fewer lines scanned than expected
Switch from none to autobuild or manual; verify the build compiles all source.
Cache miss every run
Confirm dependency-caching: true on init.
Out of disk or memory
Use larger runners, reduce scope with paths, or use build-mode: none where safe.
references/troubleshooting.md: no source code, out of disk, out of memory, 403, C# compiler, analysis too long, fewer lines, Kotlin, extraction errors, debug logging, SARIF upload, SARIF limits.
1---2name: codeql3description: Configure and run CodeQL code scanning with GitHub Actions workflows, default or advanced setup, CodeQL CLI databases, SARIF uploads, custom query packs, monorepo categories, build modes, and alert triage. Use this skill when the user asks to create or customize codeql.yml, choose CodeQL setup, configure a language matrix, run codeql database create or database analyze, upload SARIF, troubleshoot CodeQL builds, or interpret code scanning alerts.4---56<!-- Generated from harness/github-copilot/skills/codeql/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# CodeQL code scanning910Set up, run, and troubleshoot CodeQL analysis through GitHub Actions or the CodeQL CLI, producing a working workflow, local commands, SARIF upload path, and alert triage guidance.1112## When to invoke1314- "Create a CodeQL workflow for this repository."15- "Should we use default setup or advanced setup for code scanning?"16- "Run CodeQL CLI locally and upload SARIF."17- "Troubleshoot this CodeQL build-mode failure."18- "Configure CodeQL for a monorepo with custom query packs."1920## Prerequisites and context2122- GitHub code scanning must be available for the repository.23- Advanced setup uses `.github/workflows/codeql.yml` and may use `.github/codeql/codeql-config.yml`.24- CLI uploads require `GITHUB_TOKEN` with `security-events: write` plus repository, ref, and commit metadata.25- Use the CodeQL bundle from https://github.com/github/codeql-action/releases, not a standalone CLI download, so bundled queries and precompiled packs match the CLI.2627## Supported languages2829| Language | Standard identifier | Alternatives | Build notes |30| --- | --- | --- | --- |31| C/C++ | `c-cpp` | `c`, `cpp` | compiled; choose `none`, `autobuild`, or `manual`. |32| C# | `csharp` | — | compiled; watch `/p:EmitCompilerGeneratedFiles=true` conflicts with `.sqlproj` or legacy projects. |33| Go | `go` | — | usually autobuilds through standard Go tooling. |34| Java/Kotlin | `java-kotlin` | `java`, `kotlin` | Kotlin no-build mode may need default setup disabled and re-enabled to switch to `autobuild`. |35| JavaScript/TypeScript | `javascript-typescript` | `javascript`, `typescript` | alternative identifiers still analyze both JS and TS. |36| Python | `python` | — | no build mode required. |37| Ruby | `ruby` | — | no build mode required. |38| Rust | `rust` | — | build mode can matter for extraction completeness. |39| Swift | `swift` | — | compiled; runner and build environment matter. |40| GitHub Actions | `actions` | — | analyzes workflow code. |4142## GitHub Actions workflow43441. Choose setup type.45 - **Default setup**: enable in repository Settings → Advanced Security → CodeQL analysis. Best for fast onboarding; uses `none` build mode for most languages.46 - **Advanced setup**: commit `.github/workflows/codeql.yml` for full control over triggers, build modes, query suites, path filters, custom packs, and monorepos. Disable default setup before switching to advanced.472. Configure triggers. Use `push`, `pull_request`, `schedule`, and `merge_group` when merge queues are enabled. `paths-ignore` controls whether the workflow runs, not which files are analyzed.483. Set least-privilege permissions: `security-events: write`, `contents: read`, and `actions: read` for private repositories using `codeql-action`.494. Use a matrix with `fail-fast: false` and one row per language/build-mode pair.505. Initialize, build if needed, analyze, and set a unique `category` such as `/language:${{ matrix.language }}` or `/language:${{ matrix.language }}/component:frontend`.5152```yaml53name: CodeQL54on:55 push:56 branches: [main, protected]57 pull_request:58 branches: [main]59 schedule:60 - cron: '30 6 * * 1'61 merge_group:6263permissions:64 security-events: write65 contents: read66 actions: read6768jobs:69 analyze:70 name: Analyze (${{ matrix.language }})71 runs-on: ubuntu-latest72 strategy:73 fail-fast: false74 matrix:75 include:76 - language: javascript-typescript77 build-mode: none78 - language: python79 build-mode: none80 steps:81 - uses: actions/checkout@v482 - uses: github/codeql-action/init@v483 with:84 languages: ${{ matrix.language }}85 build-mode: ${{ matrix.build-mode }}86 queries: security-extended87 dependency-caching: true88 - if: matrix.build-mode == 'manual'89 run: |90 make bootstrap91 make release92 - uses: github/codeql-action/analyze@v493 with:94 category: "/language:${{ matrix.language }}"95```9697## Configuration choices9899| Need | Configuration |100| --- | --- |101| Broader security coverage | `queries: security-extended`. |102| Security plus quality checks | `queries: security-and-quality`. |103| Custom query packs | `packs: my-org/my-security-queries@1.0.0` or `codeql/javascript-queries:AlertSuppression.ql`. |104| Monorepo component isolation | Distinct `category` values and `.github/codeql/codeql-config.yml`. |105| Analyze only selected paths | `paths:` and `paths-ignore:` in `.github/codeql/codeql-config.yml`. |106| Dependency reuse | `dependency-caching: true` on `github/codeql-action/init@v4`. |107| Version stability | Pin `github/codeql-action/init@v4`, `github/codeql-action/autobuild@v4`, and `github/codeql-action/analyze@v4`; pin full commit SHAs for maximum security. |108109```yaml110paths:111 - apps/112 - services/113paths-ignore:114 - '**/test/**'115 - node_modules/116queries:117 - uses: security-extended118packs:119 javascript-typescript:120 - my-org/my-custom-queries121```122123## CodeQL CLI workflow124125```bash126export PATH="$HOME/codeql:$PATH"127codeql resolve packs128codeql resolve languages129130codeql database create codeql-db \131 --language=javascript-typescript \132 --source-root=src133134codeql database create codeql-dbs \135 --db-cluster \136 --language=java,python \137 --command=./build.sh \138 --source-root=src139140codeql database analyze codeql-db \141 javascript-code-scanning.qls \142 --format=sarif-latest \143 --sarif-category=javascript \144 --output=results.sarif145146codeql github upload-results \147 --repository=owner/repo \148 --ref=refs/heads/main \149 --commit=<commit-sha> \150 --sarif=results.sarif151152codeql execute cli-server153```154155Common suites are `<language>-code-scanning.qls`, `<language>-security-extended.qls`, and `<language>-security-and-quality.qls`. Use `--command` for compiled-language database creation. Use `--verbosity=progress++` and `--logdir=codeql-logs` for local debug logs.156157## Alerts, logs, and limits158159| Topic | Guidance |160| --- | --- |161| Severity | Standard severity is `Error`, `Warning`, or `Note`; security severity is `Critical`, `High`, `Medium`, or `Low` from CVSS and takes display precedence. |162| PR alerts | Alerts appear as check annotations on changed lines; checks fail by default for `error`, `critical`, or `high`. |163| False positives | Dismiss only with a documented reason for audit history. |164| GitHub Copilot Autofix | Review generated fixes carefully before committing; no Copilot subscription is required for CodeQL alert suggestions in PRs. |165| Logs | Review lines of code in codebase, lines extracted, extraction errors/warnings, and debug logging from workflow reruns. |166| SARIF | Use `--sarif-category` to split results; SARIF uploads have a 10 MB file size limit. |167| Runners | Small codebases need about 8 GB RAM and 2 cores; medium 16 GB and 4–8 cores; large 64 GB and 8 cores. All need SSD storage with at least 14 GB free. |168169## Troubleshooting170171| Problem | Resolution |172| --- | --- |173| Workflow not triggering | Verify `on:` event, branches, paths filters, and that the workflow exists on the target branch. |174| `Resource not accessible` | Add `security-events: write` and `contents: read`; add `actions: read` for private repos using `codeql-action`. |175| Autobuild failure | Switch to `build-mode: manual` and add explicit build commands between init and analyze. |176| No source code seen | Verify `--source-root`, language identifier, path config, and build command. |177| Fewer lines scanned than expected | Switch from `none` to `autobuild` or `manual`; verify the build compiles all source. |178| Cache miss every run | Confirm `dependency-caching: true` on `init`. |179| Out of disk or memory | Use larger runners, reduce scope with `paths`, or use `build-mode: none` where safe. |180| SARIF upload fails | Check `security-events: write`, `GITHUB_TOKEN`, SARIF size, `--sarif-category`, repository, ref, and commit SHA. |181| Two CodeQL workflows | Disable default setup or remove the old advanced workflow. |182| Slow analysis | Enable dependency caching, use `--threads=0`, reduce query suite scope, or split monorepo categories. |183184## Progressive disclosure and bundled resources185186Read bundled references only when the main skill is insufficient for the current task.187188- `references/workflow-configuration.md`: triggers, schedules, `paths-ignore`, `db-location`, model packs, alert severity, merge protection, concurrency, config files.189- `references/cli-commands.md`: `database create`, `database analyze`, `upload-results`, `resolve packs`, `cli-server`, installation, CI integration.190- `references/sarif-output.md`: `sarifLog`, `result`, `location`, `region`, `codeFlow`, `fingerprint`, `suppression`, upload limits, third-party support, `precision`, `security-severity`.191- `references/compiled-languages.md`: `C/C++`, `C#`, `Java`, `Go`, `Rust`, `Swift`, `autobuild`, `build-mode`, hardware, dependency caching.192- `references/troubleshooting.md`: no source code, out of disk, out of memory, `403`, C# compiler, analysis too long, fewer lines, Kotlin, extraction errors, debug logging, SARIF upload, SARIF limits.193- `references/alert-management.md`: severity, security severity, CVSS, GitHub Copilot Autofix, dismissals, triage, PR alerts, data flow, merge protection, REST API.194195## Technical index196197Preserve these CodeQL reference search terms, commands, and troubleshooting labels when narrowing the workflow: `codeql.yml`, `codeql database create`, `github upload-results`, `config-file`, `packs:`, `my-org/my-queries`, `my-queries`, `per-component`, `per-language`, `documentation-only`, `auto-generated`, `re-run`, `re-enable`, `disk/memory`, `branches`, `trigger`, `analyze`, `installation`, `CI integration`, `concurrency`, `config file`, `dependency caching`, `hardware`, `model packs`, `merge protection`, `alert severity`, `security severity`, `severity`, `triage`, `dismiss`, `PR alerts`, `data flow`, `REST API`, `Copilot Autofix`, `C# compiler`, `Kotlin`, `debug logging`, `extraction errors`, `errors/warnings**`, `fewer lines`, `no source code`, `out of disk`, `out of memory`, `analysis too long`, `SARIF upload`, `SARIF limits`, and `upload limits`.198199## Output template200201```markdown202## CodeQL setup result203204**Status:** configured | commands provided | blocked205**Mode:** default setup | advanced setup | CLI206**Languages:** <language identifiers>207208### Files or commands209- `.github/workflows/codeql.yml`: <created/updated/not needed>210- `.github/codeql/codeql-config.yml`: <created/updated/not needed>211- CLI command: `<codeql ...>`212213### Key settings214| Setting | Value | Reason |215| --- | --- | --- |216| `build-mode` | `<none/autobuild/manual>` | <why> |217| `queries` | `<suite or packs>` | <why> |218| `category` | `<category>` | <why> |219220### Validation221- Workflow syntax: <checked/not checked>222- CodeQL init/analyze or CLI run: <pass/fail/not run>223- SARIF upload readiness: <pass/fail/not applicable>224```225226## Quality gate227228- [ ] Setup type is explicit: default, advanced, or CLI.229- [ ] Language identifiers use CodeQL-supported names or documented alternatives.230- [ ] Compiled languages have a deliberate `build-mode` and manual commands when needed.231- [ ] Workflow permissions include only required permissions, especially `security-events: write`.232- [ ] Query suites, packs, path filters, dependency caching, and categories are justified.233- [ ] CLI instructions use the CodeQL bundle, create a database, analyze it, and upload SARIF only with a valid `GITHUB_TOKEN`.234- [ ] Troubleshooting advice maps to the observed failure rather than generic rebuild advice.235236## References237238- [CodeQL Action releases](https://github.com/github/codeql-action/releases)
Run npx skillmds@latest add paulasilvatech/codeql in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Configure and run CodeQL code scanning with GitHub Actions workflows, default or advanced setup, CodeQL CLI databases, SARIF uploads, custom query packs, monorepo categories, build modes, and alert triage. Use this skill when the user asks to create or customize codeql.yml, choose CodeQL setup, configure a language matrix, run codeql database create or database analyze, upload SARIF, troubleshoot CodeQL builds, or interpret code scanning alerts. It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
paulasilvatech (@paulasilvatech) published this skill. Their other Agent Skills are listed on their SkillMD profile.