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

# Forma

> A forma is an infrastructure declaration: the unit formae applies, extracts, or destroys.

A forma (plural: formae) is an infrastructure declaration. When you apply a forma, formae processes it to create, update, or delete resources.

A forma defines the exact scope of change, whether that's an entire environment or a single update. You can manage your deployment at any level of granularity, without being forced to touch unrelated resources.

Formae support three operations:

* [`apply`](/documentation/reference/cli) a forma to provision or modify infrastructure
* [`extract`](/documentation/reference/cli) a forma from existing resources, capturing their current state so you can reuse it elsewhere
* [`destroy`](/documentation/reference/cli) a forma to decommission the resources it declares

A forma can be temporary (used once) or committed to version control for long-term management.

## Example

```pkl theme={"languages":{"custom":["/languages/pkl.json"]}}
amends "@formae/forma.pkl"
import "@formae/formae.pkl"
import "@aws/aws.pkl"
import "@aws/s3/bucket.pkl"

forma {
  new formae.Stack {
    label = "my-app"
    description = "My application stack"
  }

  new formae.Target {
    label = "my-aws-target"
    config = new aws.Config {
      region = "us-east-1"
    }
  }

  new bucket.Bucket {
    label = "app-bucket"
    bucketName = "my-unique-bucket-name"
  }
}
```

Every forma includes at least one [stack](/documentation/concepts/stack) to organize resources and at least one [target](/documentation/concepts/target) to specify where they're applied.

<Note>
  This example uses `amends "@formae/forma.pkl"`. `formae project init` now generates `extends "@formae/forma.pkl"` instead, which additionally lets you declare typed CLI [properties](/documentation/concepts/properties). Both forms are supported.
</Note>

<Note>
  A forma might not complete successfully: failures can occur between the agent and the target systems. Incomplete execution leaves infrastructure in a consistent state. If the failure is recoverable or caused by bad input, reapply the forma. The agent retries when it can.
</Note>

## See also

* [Write your first forma](/documentation/get-started/write-your-first-forma): structure, properties, and resource references, hands-on
* [Stack](/documentation/concepts/stack): how resources are grouped for lifecycle management
* [Target](/documentation/concepts/target): where a forma's resources are applied
