agentleFS
Cogni-AI-OUCogni-AI-OU/cogni-ai-agent-skills/codeql/SKILL.md

codeql

Skill4 starsChanged 6 months agoMITView on GitHub

Configure and execute CodeQL code scanning analysis via GitHub Actions workflows and the CodeQL CLI.

  • Reads credentials

12 other projects use a version of this, 3 of them edited.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 4 are distinctive, and 9 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When configuring advanced CodeQL security scanning via GitHub Actions (.github/workflows/codeql.yml).

    line 15
  2. Distinctive:

    When troubleshooting CodeQL autobuild failures for compiled languages like C++ or Java.

    line 17
  3. Distinctive:

    When running standard linters (like ESLint or Ruff) that do not use CodeQL's semantic analysis.

    line 21
  4. Distinctive:

    If the repository has explicitly disabled CodeQL in favor of a different enterprise SAST tool.

    line 23
  5. Very specific:

    Set Permissions: Ensure security-events: write and contents: read permissions.

    line 35
  6. Very specific:

    Initialize CodeQL: Use github/codeql-action/init@v4 specifying build-mode (none, autobuild, manual).

    line 37
  7. Very specific:

    Analyze: Use github/codeql-action/analyze@v4 to perform analysis and upload SARIF results.

    line 39
  8. Very specific:

    Out of disk/memory: Use larger runners, reduce scope via paths config, or use build-mode: none.

    line 87
  9. Very specific:

    Resource not accessible: Verify security-events: write permission is granted.

    line 88
  10. Very specific:

    SARIF upload fails: Check if SARIF file exceeds 10 MB limit.

    line 89
  11. Very specific:

    Use security-extended or security-and-quality for comprehensive vulnerability coverage.

    line 109
  12. Distinctive:

    Avoid using the standalone CodeQL CLI download.

    line 116
  13. Very specific:

    Avoid using autobuild for complex compiled language setups where a custom build is required.

    line 117

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: codeql

<!-- markdownlint-disable MD013 MD023 MD031 MD032 -->

This skill provides procedural guidance for configuring and running CodeQL code scanning — both through GitHub Actions workflows and the standalone CodeQL CLI.

When to Use

  • When configuring advanced CodeQL security scanning via GitHub Actions (.github/workflows/codeql.yml).
  • To manually build CodeQL databases and run queries using the standalone CodeQL CLI.
  • When troubleshooting CodeQL autobuild failures for compiled languages like C++ or Java.

When Not to Use

  • When running standard linters (like ESLint or Ruff) that do not use CodeQL's semantic analysis.
  • For managing third-party dependency vulnerabilities (use Dependabot or the sbom skill).
  • If the repository has explicitly disabled CodeQL in favor of a different enterprise SAST tool.

Common Pitfalls

  • Autobuilding Complex Projects: Relying on build-mode: autobuild for compiled languages with complex, non-standard build scripts, resulting in empty databases.
  • Missing Write Permissions: Forgetting to add security-events: write to the GitHub Actions job, causing the SARIF upload step to fail with HTTP 403.
  • Disk Space Exhaustion: Running CodeQL on massive monorepos without filtering paths or using caching, exhausting the GitHub Actions runner's disk space.

Core Process

  1. Choose Setup Type: Select between Default setup or Advanced setup (.github/workflows/codeql.yml).
  2. Configure Triggers: Define push, pull_request, schedule, or merge_group workflow triggers.
  3. Set Permissions: Ensure security-events: write and contents: read permissions.
  4. Configure Language Matrix: Specify languages (e.g., c-cpp, javascript-typescript, python).
  5. Initialize CodeQL: Use github/codeql-action/init@v4 specifying build-mode (none, autobuild, manual).
  6. Build (if needed): Provide explicit manual build steps for compiled languages lacking autobuild support.
  7. Analyze: Use github/codeql-action/analyze@v4 to perform analysis and upload SARIF results.

Quick Start (Advanced Setup)

name: "CodeQL Advanced"
on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
jobs:
  analyze:
    name: Analyze (${{ matrix.language }})
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      contents: read
    strategy:
      fail-fast: false
      matrix:
        include:
          - language: javascript-typescript
            build-mode: none
    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v4
      with:
        languages: ${{ matrix.language }}
        build-mode: ${{ matrix.build-mode }}
        queries: security-extended
        dependency-caching: true
    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v4

Commands / Usage Patterns (CodeQL CLI)

  • Create Database: codeql database create codeql-db --language=javascript-typescript --source-root=src
  • Create DB with Build Command: codeql database create codeql-db --language=c-cpp --command="make build"
  • Analyze Database: codeql database analyze codeql-db javascript-code-scanning.qls --format=sarif-latest --output=results.sarif
  • Upload Results: codeql github upload-results --repository=owner/repo --ref=refs/heads/main --commit=<commit-sha> --sarif=results.sarif

Diagnostics and Troubleshooting

  • Autobuild failure: Switch build-mode to manual and add explicit build commands.
  • Out of disk/memory: Use larger runners, reduce scope via paths config, or use build-mode: none.
  • Resource not accessible: Verify security-events: write permission is granted.
  • SARIF upload fails: Check if SARIF file exceeds 10 MB limit; ensure GITHUB_TOKEN is valid.
ProblemSolution
Workflow not triggeringVerify on: triggers match event; check paths/branches filters; ensure workflow exists on target branch
Resource not accessible errorAdd security-events: write and contents: read permissions
Autobuild failureSwitch to build-mode: manual and add explicit build commands
No source code seenVerify --source-root, build command, and language identifier
C# compiler failureCheck for /p:EmitCompilerGeneratedFiles=true conflicts with .sqlproj or legacy projects
Fewer lines scanned than expectedSwitch from none to autobuild/manual; verify build compiles all source
Kotlin in no-build modeDisable and re-enable default setup to switch to autobuild
Cache miss every runVerify dependency-caching: true on init action
Out of disk/memoryUse larger runners; reduce analysis scope via paths config; use build-mode: none
SARIF upload failsEnsure token has security-events: write; check 10 MB file size limit
SARIF results exceed limitsSplit across multiple uploads with different --sarif-category; reduce query scope
Two CodeQL workflowsDisable default setup if using advanced setup, or remove old workflow file
Slow analysisEnable dependency caching; use --threads=0; reduce query suite scope

Best Practices

  • Use security-extended or security-and-quality for comprehensive vulnerability coverage.
  • Set dependency-caching: true on the init action to optimize run times.
  • For monorepos, use the category parameter in the analyze step to separate component results.
  • Pin GitHub actions to specific major versions (e.g., @v4) or commit SHAs for better security.

What to Avoid

  • Avoid using the standalone CodeQL CLI download; always use the CodeQL bundle which includes precompiled queries.
  • Avoid using autobuild for complex compiled language setups where a custom build is required.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.