Netherframe Cheat Sheet
A single-page quick reference for daily nf terminal work, Python authoring, lifecycle
rules, checks, and exit codes.
Project setup (pyproject.toml)
[tool.nf]
apps = ["infra.app:web"] # hybrid apps (alias: hybrid_apps)
terraform_apps = ["legacy.app:net"] # optional Terraform JSON export (alias: legacy_apps)
[tool.nf.config]
max_concurrent_resources = 20
recovery_strategy = "checkpoint" # checkpoint | rollback | none
backend_type = "s3"
backend_s3_bucket = "acme-nf-state"
backend_s3_key_prefix = "web"
[tool.nf.tui]
skin = "charm" # k9s | charm | charm-dark | charm-light | light | terminal
keymap = "k9s" # k9s | emacs
readonly = ["prod_web"]
Essential CLI commands
| Task |
Command |
| List apps & inputs |
nf list apps · nf vars --app web |
| Generate & install provider bindings |
nf generate providers hashicorp/aws --version 6.73.0 --yes |
| Preview changes with attribute diffs |
nf plan --app web ++env=prod --diff |
| Save an immutable whole-app plan |
nf plan --app web ++env=prod --out plan.json |
| Inspect a saved plan offline |
nf show --plan-file plan.json |
| Apply the exact saved plan |
nf apply --app web --plan-file plan.json |
| Plan + apply interactively in one step |
nf deploy --app web ++env=dev |
| Destroy (uses last apply's inputs) |
nf destroy --app web · nf destroy --app web ++keep_data |
CI drift check (exits 3 on changes) |
nf plan --app web --expect-no-changes --json |
| Source-level drift detect / check / fix |
nf drift detect · nf drift check · nf drift fix --dry-run |
| Offline policy lint |
nf lint --app infra.app:web --all-failures |
| Interactive terminal UI |
nf tui --app web · nf tui --readonly · nf tui follow |
| Follow a remote/CI apply |
nf follow --app web |
| Show / bootstrap / validate backend |
nf backend show · nf backend bootstrap · nf backend validate |
| Rename / forget / taint state entry |
nf state mv --app web OLD NEW · nf state rm · nf state taint |
| Inspect & resume finalizers after crash |
nf state runs --app web · nf state verify --app web |
| Convert Terraform HCL to Python |
nf convert ./tf-module ./out |
| Shell completion & AI agent skill |
nf completion bash\|zsh\|fish · nf skill install --path PATH |
nf plan --app web ++env=prod ++replicas=4 # typed scalars & booleans (++flag)
nf plan --app web ++regions=us-east-1,eu-west-1 # list / tuple
nf plan --app web ++@envs/prod.toml ++replicas=6 # TOML/JSON file + CLI override
nf apply --app id ++@<(printf '{"secret":"%s"}' "$SEC") # Secret[str] (refused on argv)
Authoring syntax & nf_autoid
# coding: nf_autoid
from typing import Literal
from nf.core import App, AppCheckContext, Bind, BindContext, LifecycleRules, Output, Stack, Teardown
from nf.providers.hashicorp.random import Pet, RandomProvider
def no_prod_deletes(ctx: AppCheckContext) -> str | None:
if ctx.inputs["env"] == "prod" and (doomed := ctx.changes_of(actions=("delete", "replace"))):
return f"blocked: {', '.join(c.address for c in doomed)}"
return None
def demo(env: Literal["dev", "prod"] = "dev", keep: Teardown[bool] = False) -> App:
with App(nf_id="demo", recovery_strategy="ROLLBACK") as app, Stack(nf_id=f"s-{env}"), BindContext:
random: Bind = RandomProvider() # nf_id="random" injected
pet: Bind[Pet] = Pet( # nf_id="pet" injected
nf_provider=random,
length=2,
lifecycle=LifecycleRules(retain="keep across destroy") if keep else None,
)
pet_name: Bind = Output(value=pet.output.id)
app.check(no_prod_deletes, phase="apply")
return app
- Rewritten by
nf_autoid: name: Bind = ..., name: Bind[T] = ..., with Construct() as name, BindContext:
- Never rewritten: plain assignments
x = Pet(...) (pass nf_id="x" explicitly).
LifecycleRules & app.check phases
LifecycleRules option |
Effect (hybrid) |
prevent_destroy=True |
Blocks delete & replace at plan time and refuses nf destroy |
ignore_changes=["tags"] / "all" |
Keeps prior-state values for ignored paths on updates |
replace_triggered_by=[res] |
Forces replacement when res has a planned change |
retain="why" / retain=False |
Keeps object in state through nf destroy, protects deps, runs @retained_check |
adopt=True / "required" |
Adopts existing object by provider resource identity |
app.check phase |
Runs when |
prerequisites |
Before reading or creating state (sees ctx.inputs) |
plan |
After plan creation (sees ctx.changes, ctx.state) |
apply (default) |
Under state lock before approval (sees ctx.changes, ctx.state) |
finalize |
Under state lock after apply/destroy regardless of outcome (sees ctx.run, returns Finalized) |
Python SDK (nf.sdk)
from nf.sdk import Project
def run_plan(root: str) -> bool:
project = Project(root, settings={"max_concurrent_resources": 20}, inputs={"env": "prod"})
plans = project.plan(app="web", plan_out="prod.plan.json")
return plans.has_changes
Exit codes
| Code |
Meaning |
0 |
Success (no changes / no drift) |
1 |
Runtime, execution, config, lint, or check error |
2 |
CLI usage / option error |
3 |
Changes or drift detected (nf plan --expect-no-changes, nf drift check\|detect) |
4 |
Incomplete apply with deferred changes remaining (default incomplete_exit_code) |
124 |
Timeout (nf follow --timeout) |
130 |
Interrupted (repeated Ctrl-C) |
Full references
CLI Reference · Exit Codes · Settings · Resource Lifecycle · Provider Bindings · nf.core · nf.sdk