Skip to main content
Skip to content

Creating CodeQL query suites

You can create query suites for queries you frequently use in your CodeQL analyses.

Who can use this feature?

CodeQL is available for the following repository types:

You can create query suites for the queries that you want to frequently use in your CodeQL analyses. For more information, see CodeQL query suites.

Note

Any custom queries that you want to add to a query suite must be in a CodeQL pack and contain the correct query metadata. For more information, see Writing custom queries for the CodeQL CLI.

Locating queries to add to a query suite

When creating a query suite, you first need to specify the locations of the queries that you want to select. You can define the location of one or more queries using:

  • A query instruction: Tells CodeQL to look for one or more specified .ql files:

    - query: <path-to-query>
    

    The argument must be one or more file paths, relative to the CodeQL pack containing the suite definition.

  • A queries instruction: Tells CodeQL to recursively scan a directory for .ql files:

    - queries: <path-to-subdirectory>
    

    The path of the directory must be relative to the root of the CodeQL pack that contains the suite definition file. To find the queries relative to a different CodeQL pack, add a from field:

    - queries: <path-to-subdirectory>
      from: <ql-pack-name>
      version: ^x.y.z
    

    The version field is optional and specifies a range of compatible versions of this CodeQL pack. If you don’t specify a version, then the most recent version of the pack is used.