> ## Documentation Index
> Fetch the complete documentation index at: https://site.aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and update BUILD files

> Learn how to create and update Bazel BUILD files automatically with Gazelle, and when to author them manually using macros, examples, and the #keep directive.

## Automatic `BUILD` generation

In most languages, `BUILD` files can be automatically created and updated by running this command:

```python theme={null}
 aspect gazelle
```

The gazelle tool indexes the source code structure, similar to how an editor or IDE provides jump-to-definition. BUILD generators rely on conventions to decide what to create:

* `srcs` contains all files in the current package with the typical file extension.
* `deps` can be determined by looking at all the `import` statements in the `srcs`
  and mapping them to labels which provide that symbol.
* tests can be separated out by a file convention

<Note>
  The 200-series courses discuss how to modify or extend the conventions, either using Gazelle’s Go API, or using the same “Starlark” language as Bazel rules and macros.
</Note>

## Manual `BUILD` Authoring.

In some cases, there’s no BUILD generator for your language, or it doesn’t include the feature you need for configuration. In this case, you will edit `BUILD` files on your own.

1. Look around the repo for examples.
2. Ask your DevInfra team to provide more documentation, or write the missing `BUILD` generator.
3. Consider using Macros to reduce the boilerplate you have to type.
4. Use `#keep` to avoid the BUILD generator changing your code.
