> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
