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

# Introduction

> Hands-on course for automating BUILD file generation with Gazelle and Starlark, including writing custom Gazelle extensions for new languages.

> [!NOTE]
>
> Writing Bazel BUILD files by hand requires knowing its configuration language — a barrier for many engineers. This course removes that friction by generating BUILD files automatically.

Bazel makes you declare your dependency graph in `BUILD` files *before* it will build anything. Maintaining those files by hand is tedious and error-prone. **Gazelle** reads your source code and writes the `BUILD` files for you, and the **Aspect CLI** lets you teach Gazelle about new languages and conventions using **Starlark** — no Go required.

This is a practical, hands-on tutorial. By the end you'll be able to generate BUILD files for your repository and extend that generation to your own rules and file types.

## What you'll learn

* Why Bazel needs BUILD file generation, and how Gazelle fills the gap.
* How Gazelle scans your project and produces accurate, non-destructive build targets.
* How to configure Gazelle with directives for real-world repository layouts.
* How to write extensions in **Starlark** to support new languages, custom rules, and project conventions — and how to test them.

## Prerequisites

* A working knowledge of Bazel and `BUILD` files. New to Bazel? Start with [Bazel 101](https://aspect.build/learning/bazel-101.md).
* The free [Aspect CLI](https://aspect.build/docs/cli.md) installed (the Starlark extension API ships with it).

## Course contents

> [card] [Why generate BUILD files](https://aspect.build/learning/aspect-150/motivation.md)
>
> The problem Gazelle solves: Starlark friction, hand-maintained dependency graphs, and the gap between infra experts and product engineers.

> [card] [Intro to Gazelle](https://aspect.build/learning/aspect-150/gazelle.md)
>
> Where Gazelle came from and how it walks your source tree to generate and merge BUILD files without clobbering your edits.

> [card] [Install](https://aspect.build/learning/aspect-150/install.md)
>
> Run a prebuilt Gazelle binary the easy way, and learn why that beats building from source.

> [card] [Available languages](https://aspect.build/learning/aspect-150/languages.md)
>
> Which languages Gazelle supports out of the box, who maintains each extension, and why writing your own is often the right call.

> [card] [Configuration](https://aspect.build/learning/aspect-150/config.md)
>
> Steer Gazelle with directives like `exclude`, `map_kind`, and `resolve` — and when to avoid directives entirely.

> [card] [The Starlark extension API](https://aspect.build/learning/aspect-150/orion.md)
>
> Meet "orion", the Aspect CLI extension API. Register rule kinds and declare targets in a few lines of Starlark.

> [card] [Query API](https://aspect.build/learning/aspect-150/query-api.md)
>
> Inspect source files with regex and tree-sitter AST queries to detect imports, tests, and any syntax you care about.

> [card] [Examples](https://aspect.build/learning/aspect-150/examples.md)
>
> Real Starlark extensions: ports from Go, plus from-scratch generators for PostCSS and C++.

> [card] [Extending existing languages](https://aspect.build/learning/aspect-150/extending.md)
>
> Augment the stock Gazelle binary with small Starlark extensions — OCI images, lint tests, codegen targets, and more.

> [card] [Testing](https://aspect.build/learning/aspect-150/testing.md)
>
> Verify your extensions with Gazelle's golden-file test fixtures — for both Go and Starlark generators.

## Watch the talk

Prefer to watch first? Here's the live presentation of this course:

[Aspect 150 — BUILD file generators in Starlark](https://streamyard.com/e/yi3auyb3h7tk)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.