# Run Atlas Headless in CI with Astro in 2026

> Run Atlas headless in CI for Astro projects using `atlas run --format json` to automate tasks and receive machine-readable output.

To run an Atlas session non-interactively in a CI pipeline and retrieve machine-readable output for your Astro project, use the `atlas run --format json` command. This approach integrates direct with your existing Astro toolchain, allowing Atlas to interact with `astro.config.mjs`, `src/pages` routes, and `src/content.config.ts` while respecting `pnpm` for package management and `vitest` for testing, ensuring your Astro codebase remains consistent and verifiable in 2026.

## Key takeaways

- Use `atlas run --format json` to get machine-readable output for Astro CI pipelines.
- Pre-approve Atlas tools like `bash` and `edit` in configuration for uninterrupted headless Astro operations.
- Atlas understands Astro's `astro.config.mjs`, `src/pages` routes, and `.astro` component structure.
- Unified diffs are generated for all Atlas-made changes, providing an audit trail for Astro project modifications.
- Integrate Atlas direct with `pnpm`, `vitest`, and `prettier-plugin-astro` in your Astro CI workflow.

## How to run Atlas headless in an Astro CI pipeline?

In 2026, running Atlas headless in an Astro CI pipeline involves invoking `atlas run` with a single prompt, ensuring non-interactive execution. This command streams events to stdout and exits when the session goes idle, providing a clear, one-pass operation for automated tasks within your Astro project.

Running Atlas headless in your Astro CI pipeline is achieved by using the `atlas run` command. This command is specifically designed for non-interactive environments, sending a single prompt to Atlas and then streaming all session events to standard output. Once the Atlas session goes idle, the command exits, making it ideal for automated pipeline steps. For instance, you might prompt Atlas to 'Add a new Zod schema to the `authors` content collection in `src/content.config.ts`'. Atlas will then process this request, leveraging its understanding of Astro's project structure, including `astro.config.mjs`, `src/pages` routes, and content collection schemas. This allows for automated code generation, refactoring, or analysis directly within your Astro codebase without requiring manual intervention, integrating smoothly with your `pnpm` managed dependencies.

## How to get machine-readable output from Atlas in Astro CI?

To obtain machine-readable output from Atlas for subsequent pipeline steps in your Astro project, pass the `--format json` flag to `atlas run`. This ensures that instead of human-readable prose, Atlas streams raw event data, which can be parsed by other tools in your CI environment, providing structured data for 2026's advanced automation needs.

When integrating Atlas into an Astro CI pipeline, machine-readable output is crucial for automated processing. By appending `--format json` to your `atlas run` command, Atlas will stream its session events as raw JSON objects to stdout. This structured output can then be easily parsed by other tools or scripts in your CI workflow, allowing for programmatic verification, logging, or triggering of subsequent actions. For example, after Atlas modifies a `.astro` component to drop an unnecessary `client:load` directive, the JSON output will contain details of the file edit, including the unified diff. This enables your CI system to automatically review the change, run `pnpm vitest` to confirm no regressions, or even trigger `pnpm prettier --write .` to ensure formatting with `prettier-plugin-astro` is applied consistently before merging.

## How to pre-approve Atlas tools for headless Astro runs?

For headless Atlas runs in an Astro CI environment, pre-approving necessary tools via the permission configuration is crucial, as there's no interactive user to respond to `ask` prompts. This ensures Atlas can execute actions like `read`, `edit`, `bash`, or `todowrite` without interruption, maintaining pipeline flow in 2026.

In a headless CI environment, Atlas cannot prompt a user for permission to execute tools. Therefore, it is essential to pre-configure Atlas's permission settings to `allow` the tools required for your specific Astro tasks. The permission configuration allows you to define rules for tools such as `bash`, `read`, `edit`, and `todowrite`. For an Astro project, you might `allow` Atlas to `read` files like `src/pages/**/*.astro` or `src/content.config.ts`, `edit` `.astro` components or `astro.config.mjs`, and execute `bash` commands like `pnpm install`, `pnpm vitest`, or `astro check`. This pre-approval ensures that Atlas can perform its job, such as adding a Zod schema to a content collection or modifying a `client:load` directive, without halting the CI pipeline due to an unanswered permission prompt.

## How to specify models and resume sessions for Astro CI?

When running Atlas headless in an Astro CI pipeline, explicitly setting the model using the `provider/model` form is essential, especially for GitHub paths, which reject anything else. Additionally, you can resume or fork prior sessions with `--continue`, `--session`, or `--fork`, allowing complex Astro development tasks to span multiple CI steps in 2026.

To ensure Atlas uses the correct model in your Astro CI pipeline, always specify it explicitly using the `--model provider/model` flag. For example, `atlas run --model github/copilot-gpt4`. This format is critical, particularly for providers like GitHub, which require this specific structure. Beyond initial execution, Atlas supports resuming or forking prior sessions, which is invaluable for complex or multi-stage Astro development tasks. Using `--continue <session_id>` allows a pipeline step to pick up exactly where a previous Atlas run left off, building on its context and changes. Alternatively, `--fork <session_id>` creates a new session based on an existing one, enabling parallel experimentation or alternative approaches to a problem, such as iterating on different ways to refactor a component across `src/pages` or `src/content`.

## How Atlas ensures safety and review in headless Astro edits?

Atlas ensures safety and review even in headless Astro CI runs by drafting a plan in a read-only agent and computing a unified diff for every file edit before any changes are written. This allows for post-run review of modifications to `.astro` components or `astro.config.mjs`, providing a critical audit trail in 2026.

Even in a non-interactive CI environment, Atlas maintains robust safety and review mechanisms for your Astro codebase. Before making any modifications, Atlas first drafts a plan in a read-only plan agent. This agent outlines the proposed changes without altering any files. Once a plan is approved (or implicitly allowed in a pre-approved headless setup), Atlas proceeds to the build agent. For every file edit, Atlas computes a unified diff, which is then surfaced in the `--format json` output. This means that even though no human is interactively approving the diff, your CI pipeline can still capture and log the exact changes made to `.astro` files, `astro.config.mjs`, or `src/content.config.ts`. This audit trail is crucial for maintaining code quality and understanding automated modifications, allowing for post-run review and ensuring that Atlas's edits, such as adding a Zod schema or adjusting a `client:load` directive, align with your project's standards and pass `astro check`.

## Steps

1. Configure Atlas permissions to `allow` tools like `read`, `edit`, `bash`, and `todowrite` in your Astro project's Atlas configuration file for headless execution.
2. In your CI pipeline, navigate to your Astro project directory, ensuring `astro.config.mjs` and `pnpm-lock.yaml` are present.
3. Invoke `atlas run` with your desired prompt, specifying `--format json` for machine-readable output and explicitly setting the model, for example: `atlas run "Add a new content collection schema to src/content.config.ts" --format json --model github/copilot-gpt4`.
4. Parse the JSON event stream output from `atlas run` in a subsequent CI step to extract relevant information, such as unified diffs for changes to `.astro` files or `src/content.config.ts`.
5. If Atlas proposes file edits, review the generated unified diffs within the JSON output to understand the modifications made to your Astro codebase.
6. Optionally, use `atlas run --continue <session_id>` to resume a previous session if the task requires multiple iterations, such as refining a Zod schema or adjusting `client:load` directives in Astro components.
7. After Atlas completes its task, run your Astro project's tests with `pnpm vitest` and format code with `pnpm prettier --write .` (which uses `prettier-plugin-astro`) to ensure consistency and verify changes.

## FAQ

### Can Atlas modify `astro.config.mjs` in CI?

Yes, Atlas can modify `astro.config.mjs` and other Astro configuration files. With appropriate permissions, Atlas can add integrations or adjust build settings, always generating a unified diff for review within the `--format json` output, even in a headless CI environment.

### How does Atlas handle Astro content collections headless?

Atlas can read and modify content collection schemas defined in `src/content.config.ts`. It can even add Zod schemas to content collections and run `astro check` behind a permission prompt, ensuring data integrity and type safety in your Astro project's content, all non-interactively.

### What Astro-specific formatting does Atlas support?

Atlas integrates with `prettier` and `prettier-plugin-astro`. After making edits to `.astro` files or other code, Atlas can format the changes according to your project's `prettier` configuration. This ensures consistent code style across your Astro components and other files, verifiable by running `pnpm prettier --write .`.

### Can Atlas run `vitest` tests in an Astro CI pipeline?

Yes, Atlas can execute `pnpm vitest` or any other `bash` command within your Astro project, provided the `bash` tool is pre-approved in its permissions configuration. This allows Atlas to verify its changes against your test suite as part of the automated CI workflow.

### How does Atlas ensure code quality for Astro components?

Atlas understands `.astro` islands and can, for example, suggest and implement changes like dropping unnecessary `client:load` directives. This ensures components ship as static HTML instead of JavaScript islands, optimizing your Astro project's performance and adhering to its zero-JS-by-default rendering model.

### Is it possible to debug a headless Atlas session for Astro?

While `atlas run` is non-interactive, you can debug by analyzing the `--format json` output, which provides a detailed event stream of the session. Additionally, you can use `--session <session_id>` or `--fork <session_id>` to resume or inspect a prior session interactively or in a new headless run, aiding in debugging complex Astro tasks.

### Does Atlas use local embeddings for Astro code?

Yes, Atlas can build its code index with local Ollama embeddings, keeping your Astro project's code off third-party servers. This enhances privacy and security for your `src/pages` routes, `src/content` collections, and other sensitive Astro codebase files.

---

Canonical HTML: https://runatlas.sh/resources/stacks/run-atlas-headless-in-ci-in-astro
Source of truth: aeo_pages row `/resources/stacks/run-atlas-headless-in-ci-in-astro` (segment: Stacks) (this file is generated from it, never hand-edited).
Licence: Atlas is proprietary with a free core. It is not open source and there is no public source repository.
