# Pack anatomy

A pack is a folder:

```text
my-pack/
├── dryv.pack.yaml        # the manifest: selections, templates, inputs, composition, actions
├── README.md             # shown by `dryv pack describe` and on the website
├── CHANGELOG.md
├── templates/            # resources: templates and static files (the manifest's `source`)
└── tests/                # a fixture project and a check script
```

## A real manifest

This is the TypeScript API client pack, trimmed. Read it top to bottom.

```yaml
version: dryv.pack/v1alpha1
key: unit.clients.ts-api-client
layout: unit # inject | unit
package: # unit packs describe the package they generate
  name: { $ref: "#/inputs/package_name" }
  import_root: src
source: templates # where resources live

info: # catalogue metadata (what `pack search` shows)
  title: TypeScript API Client
  version: 0.1.0
  purpose: clients
  summary: A framework-free TypeScript API client over fetch.
  languages: [typescript]
  frameworks: [fetch]
  tags: [client, sdk, typescript]

plugins: # renderers this pack needs
  - name: jinja
    extensions: [.j2]

inputs: # typed, bounded values a project may set
  package_name: { type: string, default: admin-console-api }

selections: # WHICH subjects
  models:
    subject: schema
    scope: each
  operations:
    subject: operation
    filter:
      all: { facet: http } # only operations that have an HTTP facet
    scope: each

templates: # WHAT each selection produces
  model:
    $ref: "#/selections/models"
    output:
      name: $(subject.name.kebab)
      symbol: $(subject.name.pascal)
  operation:
    $ref: "#/selections/operations"
    output:
      name: $(subject.name.kebab)
      path: [$(group.name.kebab)]
      symbol: $(subject.name.camel)
    imports: # generated-symbol dependencies between templates
      - $ref: "#/templates/model"

provides: # capabilities other packs can bind to
  operation.client: { $ref: "#/templates/operation" }
  schema.types: { $ref: "#/templates/model" }

actions:
  final:
    install:
      commands:
        - run: [(pnpm|npm|bun|yarn), install]
```

## Section by section

| Key                  | Purpose                                                                                                  | Details                                                                    |
| -------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `version`, `key`     | Contract version and the pack's stable identity (`<layout>.<purpose>.<name>`)                            | [Core model](/pack-builders/design/core-model)                             |
| `layout`             | `inject` adds files to an existing destination; `unit` generates a self-contained package or application | [Layouts and units](/pack-builders/design/layouts-and-units)               |
| `source`             | Folder holding templates and static resources                                                            | [Template filesystem](/pack-builders/design/template-filesystem)           |
| `info`               | Human and catalogue metadata. `purpose`, `summary` and `languages` are required to publish               | [Test and publish](/pack-builders/test-and-publish)                        |
| `plugins`            | Renderer name, version constraint and owned file extensions                                              | [Template servers](/pack-builders/context/template-servers)                |
| `inputs`             | Typed values a project can set; exposed to templates as the `pack` context                               | [`pack` context](/pack-builders/context/pack)                              |
| `selections`         | `subject`, `scope` (`each` or `all`), optional `filter`                                                  | [Context overview](/pack-builders/context/overview)                        |
| `templates`          | Bind templates to selections; name outputs, declare symbols, imports and exports                         | [Artifact graph](/pack-builders/context/artifact-graph)                    |
| `provides` / `needs` | Capability slots between packs                                                                           | [Composition and bindings](/pack-builders/design/composition-and-bindings) |
| `choose`             | Options a project must pick (for example the JS package manager)                                         | [Project configuration](/pack-builders/design/project-configuration)       |
| `actions`            | File and final commands for the client to run                                                            | [Actions and commands](/pack-builders/design/actions)                      |

## Subjects you can select

`schema`, `operation`, `event`, `failure`, `policy`, `expression`, `workflow`, `view`, `view.part`, `surface`, and the property kinds `property.primitive`, `property.enum`, `property.composite`, `property.literal`, `property.union`, `property.record`, `property.tuple`, `property.generic`, `property.temporal`. Each has a context page under **Context: subjects** in the sidebar.

## Scope: `each` versus `all`

| Scope  | You get                                                 | Use it for                                         |
| ------ | ------------------------------------------------------- | -------------------------------------------------- |
| `each` | One render per subject, with a singular root (`schema`) | One file per schema                                |
| `all`  | One render with a plural root (`schemas[]`)             | An index, a module, a router that lists everything |

Collection scopes such as `group` and `feature` add `group` or `feature` roots when ownership is provable.

## Ownership: managed or scaffold

A resource whose name has `.sf` immediately before the renderer extension (`main.ts.sf.hbs`) is a **scaffold**: Dryv creates it once and never overwrites your later edits. Everything else is **managed**: Dryv rewrites it, and reports a conflict if you changed it by hand. See [Starters, recipes and ownership](/pack-builders/design/ownership).
