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

# init

> Scaffold missing Charter and agent-context files in a repository.

`charter init` bootstraps a repository for Charter. It uses a create-missing-only approach: it only creates files that do not already exist, never overwrites, never deletes, and stays fully offline. Repeated runs become no-ops once all files are present, making it safe to use in scripting and CI.

## Usage

<CodeGroup>
  ```bash Interactive (default) theme={null}
  charter init
  ```

  ```bash Preview without writing theme={null}
  charter init --dry-run
  ```

  ```bash Non-interactive with strict profile theme={null}
  charter init --yes --profile strict
  ```

  ```bash Request specific agent surfaces theme={null}
  charter init --agents claude,cursor
  ```
</CodeGroup>

<Frame caption="charter init output — detected stack and created files">
  <img src="https://mintcdn.com/tashfiq/ftMhRJLuT_bAr5QL/images/screenshots/init-output.webp?fit=max&auto=format&n=ftMhRJLuT_bAr5QL&q=85&s=6bef6f65d2a0bd8fd9142e4770ec229b" alt="charter init creating files" width="1728" height="896" data-path="images/screenshots/init-output.webp" />
</Frame>

## Flags

<ResponseField name="--path" type="string">
  Target directory to scaffold. Defaults to the repository root when one is found, otherwise the current directory.
</ResponseField>

<ResponseField name="--dry-run" type="boolean">
  Print the planned file actions without writing anything. Use this to preview exactly what `init` would create before committing.
</ResponseField>

<ResponseField name="--yes" type="boolean">
  Skip prompts for non-interactive or CI use. Because `init` never overwrites existing files, this flag is effectively a no-op in most runs — it is accepted for scripting compatibility.
</ResponseField>

<ResponseField name="--profile" type="standard | strict">
  Policy profile written into the generated `charter.yaml`. Defaults to `standard`.
</ResponseField>

<ResponseField name="--agents" type="string">
  Comma-separated agent surfaces to request, such as `claude,cursor`. Controls whether agent-specific config files like `.claude/settings.json` are scaffolded. When omitted, Charter auto-detects the agent surface and falls back to `claude` if nothing is detected. `AGENTS.md` is always created regardless of this flag.
</ResponseField>

## Files It Creates

The following files are created only when they are absent:

| File                    | Purpose                                                                |
| ----------------------- | ---------------------------------------------------------------------- |
| `AGENTS.md`             | Agent context file — project summary, commands, and edit boundaries    |
| `charter.yaml`          | Policy config scaffolded with `profile: standard`                      |
| `.gitignore`            | Agent artifact patterns appended when the file is absent               |
| `ARCHITECTURE.md`       | Repo overview template                                                 |
| `.env.example`          | Environment variable references                                        |
| `.claude/settings.json` | Created when Claude is detected or explicitly requested via `--agents` |

## After Init

<Steps>
  <Step title="Review the generated files">
    Open `AGENTS.md` and tailor the project summary, commands section, and edit boundaries to your repo. The scaffolded content is intentionally generic.
  </Step>

  <Step title="Run charter doctor">
    ```bash theme={null}
    charter doctor --threshold 80
    ```

    This gives you your baseline score. A blank repo typically passes 80 immediately after `init`.
  </Step>

  <Step title="Commit the new files">
    Add the scaffolded files to version control so future scans and CI runs see them.
  </Step>
</Steps>

<Tip>
  A blank Go repo scores ≥ 80 immediately after `charter init` — measured at 95 in testing. The residual findings are typically [`AE-ENV-001`](/rules/AE-ENV-001) (no toolchain file) and [`AE-CI-002`](/rules/AE-CI-002) (CI not yet configured).
</Tip>

## Exit codes

| Code | Meaning | When                                                                                        |
| ---- | ------- | ------------------------------------------------------------------------------------------- |
| `0`  | Pass    | Scaffolding completed — files created, or all files already present (a no-op run)           |
| `2`  | Error   | Invalid flags, an unwritable target path, or a malformed `charter.yaml` to scaffold against |

## Related

<CardGroup cols={2}>
  <Card title="Policy profiles" icon="adjustments-horizontal" href="/docs/config/policy-profiles">
    What `standard` and `strict` change in the generated `charter.yaml`.
  </Card>

  <Card title="Adopt in an existing repo" icon="git-merge" href="/docs/how-to/adopt-in-existing-repo">
    Bring Charter into a repo that already has agent context files.
  </Card>

  <Card title="doctor" icon="stethoscope" href="/cli/doctor">
    Score the repo after scaffolding to get a baseline.
  </Card>
</CardGroup>
