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

# fjall remove

> Remove a resource from a Fjall application's infrastructure.ts source with the CLI codemod engine. Edits code, not AWS.

<Accordion title="Prerequisites">
  * A Fjall application created with `fjall create app` (or `fjall apps create`), so an `infrastructure.ts` file exists.
  * At least one declared resource to remove. Run `fjall list -a <app>` to see what the application currently declares.
  * Node 22 or later.
</Accordion>

<Warning>
  `fjall remove` edits source code. It does **not** delete deployed AWS resources. To tear down deployed infrastructure, use [`fjall destroy`](/cli/destroy). To apply a removal to the cloud, run [`fjall deploy`](/cli/deploy) after editing.
</Warning>

## Remove a resource from infrastructure.ts

`fjall remove` deletes a resource declaration from an application's `infrastructure.ts` using the codemod engine. Pass the resource `<type>` as a positional argument and the resource name with `-n`.

```bash theme={null}
fjall remove <type> -a <app> -n <ResourceName>
```

Valid `<type>` values: `database`, `storage`, `compute`, `messaging`, `cdn`, `network`, `pattern`, `vpc-peer`, `vpc-peer-accepter`, `cross-plan-connection`.

Resource names are PascalCase, matching the name used when the resource was added.

### Examples

```bash theme={null}
# Remove a database named ApiDb from the api application
fjall remove database -a api -n ApiDb

# Remove a storage bucket from the web application
fjall remove storage -a web -n WebAssets

# Remove a compute service, forcing through remaining references
fjall remove compute -a api -n WorkerService --force

# Remove with detailed logging
fjall remove messaging -a api -n EventsQueue --verbose
```

## What Happens

Running `fjall remove` interactively shows a dry-run preview first, then asks for confirmation before writing:

1. **Locate** the resource declaration in `infrastructure.ts` by type and name.
2. **Reference check** scans the source for other declarations that reference the resource. If references remain, the removal stops unless you pass `--force`.
3. **Dry-run preview** shows the lines that will change before any write.
4. **Backup** writes a `.bak` sidecar and a timestamped snapshot under the application's `.fjall/history` directory.
5. **Write** removes the declaration from `infrastructure.ts`.

Recover a previous state with [`fjall undo`](/cli/undo) (restores the most recent `.bak`) or `fjall history --restore <timestamp>`.

### Force removal

`--force` removes the resource even when other declarations still reference it. The resulting `infrastructure.ts` can fail type-checking until you fix the dangling references. Run `fjall validate -a <app> --deep` afterwards to surface any type errors.

### Agent mode

Pass `--agent` to emit structured output for AI agent tooling. In agent mode, add `--yes` to skip the dry-run and execute the removal in one step. Agent flags `--budget`, `--fields`, and `--full` tune the structured response.

```bash theme={null}
fjall remove database -a api -n ApiDb --agent --yes
```

## Options

| Option              | Description                                                    | Default |
| ------------------- | -------------------------------------------------------------- | ------- |
| `<type>`            | Resource type to remove (positional, required)                 | None    |
| `-a, --app <name>`  | Application to remove the resource from                        | None    |
| `-n, --name <name>` | Resource name (PascalCase)                                     | None    |
| `-f, --force`       | Remove even if references to the resource remain in the source | `false` |
| `-v, --verbose`     | Enable verbose logging                                         | `false` |
| `--non-interactive` | Force plain CLI output (no interactive UI)                     | `false` |
| `--yes`             | Skip the dry-run and execute the full operation (agent mode)   | `false` |
| `--agent`           | Emit structured output for AI agent tooling                    | `false` |
| `--budget <level>`  | Detail budget for agent output                                 | None    |
| `--fields <fields>` | Restrict agent output to specific fields                       | None    |
| `--full`            | Emit the full agent output payload                             | `false` |

## Next Steps

<CardGroup cols={2}>
  <Card title="fjall add" icon="plus" href="/cli/add">
    Add a resource to infrastructure.ts with the codemod engine.
  </Card>

  <Card title="fjall list" icon="list" href="/cli/list">
    Inspect the resources an application declares.
  </Card>

  <Card title="fjall deploy" icon="rocket" href="/cli/deploy">
    Apply infrastructure.ts changes to AWS.
  </Card>

  <Card title="Add resources" icon="layer-group" href="/deployment/add-resources">
    Learn the resource-editing workflow end to end.
  </Card>
</CardGroup>
