Hey! These docs are for version 2.8, which is no longer officially supported. Click here for the latest version, 2.18!

Pants provides several goals to provide insights into your project's structure.

Tip: Use `xargs` to pipe these goals into other Pants commands

For example:

See [Advanced target selection](🔗) for more info and other techniques to use the results.

## `list` - find your project's targets

`list` will find all targets that match the arguments.

For example, to show all targets in your project:

You can specify a file, which will find the target(s) owning that file:

## `filter` - find targets that match a predicate

`filter` is like `list`, but will only include targets that match the predicate(s).

Specify a predicate by using one of the below `filter` options, like `--target-type`. You can use a comma to OR multiple values, meaning that at least one member must be matched. You can repeat the option multiple times to AND each filter. You can prefix the filter with `-` to negate the filter, meaning that the target must not be true for the filter.

Some examples:

### `filter --target-type`

Each value should be the name of a target type, e.g. `python_source` or `resource`. Run `./pants help targets` to see what targets are registered.

### `filter --address-regex`

Regex strings for the address, such as `^dir` or `:util$`.

### `filter --tag-regex`

Regex strings for the `tags` field. Alternatively, you can use the global `--tags` option, which uses exact string matches instead of regex. See [Advanced target selection](🔗).

## `dependencies` - find a target's dependencies

Use `dependencies` to list all targets used directly by a target.

You can specify a file, which will run on the target(s) owning that file:

To include transitive dependencies—meaning the dependencies of the direct dependencies—use `--transitive`:

## `dependees` - find which targets depend on a target

The `dependees` goal finds all targets that directly depend on the target you specify.

You can specify a file, which will run on the target(s) owning that file:

To include transitive dependees—meaning targets that don't directly depend on your target, but which depend on a target that does directly use your target—use `--transitive`:

To include the original target itself, use `--closed`:

## `filedeps` - find which files a target owns

`filedeps` outputs all of the files belonging to a target, based on its `sources` field.

To output absolute paths, use the option `--absolute`:

To include the files used by dependencies (including transitive dependencies), use `--transitive`:

## `peek` - programmatically inspect a target

`peek` outputs JSON for each target specified.

You can use `--exclude-defaults` for less verbose output:

`peek` can be particularly useful when paired with [JQ](🔗) to query the JSON. For example, you can combine `./pants peek` with JQ to find all targets where you set the field `skip_flake8=True`:

## `count-loc` - count lines of code

`count-loc` counts the lines of code of the specified files by running the [Succinct Code Counter](🔗) tool.

SCC has [dozens of options](🔗). You can pass through options by either setting `--scc-args` or using `--` at the end of your command, like this:

See unexpected results? Set `pants_ignore`.

By default, Pants will ignore all globs specified in your `.gitignore`, along with `dist/` and any hidden files.

To ignore additional files, add to the global option `pants_ignore` in your `pants.toml`, using the same [syntax](🔗) as `.gitignore` files.

For example: