Skip to main content
  • 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.3 or later.
fjall remove edits source code. It does not delete deployed AWS resources. To tear down deployed infrastructure, use fjall destroy. To apply a removal to the cloud, run fjall deploy after editing.

Usage

A missing --app exits with Application name is required. Use --app flag. A missing <type> or --name exits with a validation error. Neither opens a prompt.

Resource types

<type> is one of these twelve exact values, the same set fjall add accepts: database, storage, compute, messaging, cdn, network, pattern, vpc-peer, vpc-peer-accepter, cross-plan-connection, organisation, buildkite. Anything else is refused before the file is read. fjall remove app is not a valid invocation and never touches AWS.

Resource names

Names must start with a letter and contain letters and digits only, up to 63 characters. PascalCase is the convention rather than a rule, so Analytics and analytics both validate. Use the exact name from fjall list -a <app>.

Examples

What happens

In an interactive terminal, Fjall confirms first and then runs the engine.
  1. Confirm. A screen shows the target as <type> "<Name>", the absolute path of the file, and a warning that a backup is written before overwriting. The prompt defaults to No. There is no diff and no line-level preview.
  2. Locate. The engine finds the managed XFactory.build("Name", …) call by shape.
  3. Reference check. If the declaration binds a variable, the engine walks the file for live references to that binding. Remaining references block the removal unless --force is set.
  4. Back up. The previous file is written to infrastructure.ts.bak and to a timestamped snapshot under the application’s .fjall/history directory.
  5. Write. The declaration is spliced out and any import that became unused is pruned.
The success screen reports the lines added and removed, plus any references the engine found.
With --non-interactive, --agent, or any non-TTY stdout (every CI pipe), there is no confirmation screen. The removal is applied immediately.

The reference check

The check runs only when the resource is bound to a variable, such as const analytics = DatabaseFactory.build("Analytics", …). An inline declaration with no binding has nothing to reference, so it is removed without the check. When references remain, the command fails with exit code 11 and lists each one as <file>:<line>:<column> with its surrounding source. Delete or rewire those call sites, then re-run.

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. fjall remove does not run a post-write typecheck, so check the file yourself:

Exit codes

remove uses the codemod exit-code band, so a blocked removal is distinguishable from a crash in a script.

Recovery

Both commands require --app. See fjall undo and fjall history.

Agent and CI use

Agent mode applies the removal in one step. There is no dry-run stage anywhere in the codemod engine, so --agent always writes:
The structured result carries applied, type, name, path, linesChanged, and any references the engine found. On failure it carries the error and the exit code from the table above. --yes skips the interactive confirmation screen only. It has no effect with --agent or in a non-TTY shell, where nothing prompts in the first place.

Options

Agent options

Next Steps

fjall add

Add a resource to infrastructure.ts with the codemod engine.

fjall list

Inspect the resources an application declares.

fjall undo

Restore the most recent backup after a removal.

fjall validate

Typecheck the edited infrastructure.ts before deploying.

fjall deploy

Apply infrastructure.ts changes to AWS.

Add resources

Learn the resource-editing workflow end to end.