> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/python-agent/scanning-a-build.md).

# Scanning a Build

In order to collect coverage information SeaLights agents need to first scan the Python script files for the build information.

{% hint style="info" %}
See '[Generating an Agent token](https://docs.sealights.io/knowledgebase/settings/token-access-and-management#token-list-and-token-creation-2)' for instructions on how to generate a token.
{% endhint %}

## Scanning a build <a href="#scanning-a-build" id="scanning-a-build"></a>

Scanning a build in Python is done using the Python agent with the `scan` flag:

{% code overflow="wrap" lineNumbers="true" %}

```
sl-python scan
```

{% endcode %}

you can also use the command with explicit parameters

{% code overflow="wrap" lineNumbers="true" %}

```
sl-python scan --tokenFile ./sltoken.txt --buildSessionIdFile ./path-to/buildSessionId.txt --scmType none
```

{% endcode %}

{% hint style="info" %}
See [Command Reference](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/python-agent/command-reference.md#scanning-a-build) for command details.
{% endhint %}

## Using `.slignore` to Exclude Files or Directories

Use a `.slignore` file to exclude specific Python files or directories from being scanned.\
It works like a **`.gitignore`**, giving you finer control than CLI‑only exclusions.

Create a `.slignore` file in the **project root**:

```
# Comments start with #

# Exclude virtual environments
**/venv/**
**/.venv/**

# Exclude test folders (default behavior also excludes "*tests*")
**/tests/**

# Exclude Python caches
**/__pycache__/**
**/*.pyc

# Exclude generated or vendored code
**/generated/**
**/site-packages/**

# Exclude specific legacy files
legacy/old_script.py
```

### Pattern Syntax

`.slignore` follows **`.gitignore` rules** (same as other SeaLights agents): [\[docs.sealights.io\]](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/ignoring-files-or-folders), [\[docs.sealights.io\]](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/ignoring-files-or-folders.md)

* `**` matches any directory depth
* `*` matches any characters within a directory
* Lines starting with `#` are comments
* Empty lines are ignored
* Prefix `!` to *include* something inside an excluded area

### Merge and Precedence (Simple Rules)

The Python Agent resolves configuration values using the following precedence order (highest to lowest):

1. Environment variables
2. CLI parameters (`--excludeFiles`, `--includeFiles`, and others)
3. `.slignore` file

#### Important Notes

* Environment variables always take precedence over all other configuration sources.
* CLI parameters override values defined in the `.slignore` file and default settings.
* The `.slignore` file is applied during every scan operation (test and runtime execution).
* Python Agent defaults are applied only when no explicit configuration is provided.

{% hint style="info" %}

#### Tips

* Start with minimal patterns and add more as needed.
* Inspect what’s being scanned by running the scan with high‑verbosity logs.
* Use `.slignore` for file‑level control when CLI excludes are too coarse.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/python-agent/scanning-a-build.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
