Skip to content

feat(tf): pass flags to tofu; add import, state, show, force-unlock #5318

Description

@dan-petty

Problem or Motivation

The typed short options -o, -v, -p and -u collide with tofu single-dash flags ('-out=FILE' parses as '-o ut=FILE'). The import, state, show and force-unlock verbs do not exist.

Order 4 of the plan in #5311. The owner approved the plan on 2026-11-13.

Proposed Solution & Architectural Design

The mirror verbs pass the remaining arguments to tofu without change. Remove the typed short options (alpha, no shim). Add thin verbs. --dry-run prints the tofu argv and the directory and sends no request.

Target Subsystem

OpenTofu / Infrastructure as Code

Existing Tool Considered

tofu does all of the work. No open tool adds devops pacing, the agent refusal or a dry run with zero requests.

Cost: Build: about 2.0M tokens and 3 days in 3 PRs (pass-through 1.2M, drift fix 0.3M, guard 0.5M), test first. Keep: about 50k tokens a month. Fix: about 200k tokens for each break. This item is the pass-through part: about 1.2M tokens.

Acceptance Criteria

  • A test shows that 'devops tf plan -out=x.plan -lock=false' reaches tofu unchanged.
  • docs/commands/tf.md and CLI_REFERENCE are updated.

Dependencies

No blocker (#5317 for live use). Part of #5311.

Source: #5311

Alternatives check of 2026-11-22: in-use.
The repository already uses this tool.
Tool: opentofu/opentofu (https://github.com/opentofu/opentofu), MPL-2.0, last activity 2026-11-21, maintained.
Reason: Searches found no wrapper tool; OpenTofu, already in use, supplies the engine, the four operations and the single-dash flags, but not the devops pass-through verbs, the zero-request dry run or the alias removal.

Covers:

  • Plan, import, state, show and force-unlock engine
  • Accepts single-dash flags such as -out and -lock
  • Runs a command in a given working directory

Lacks:

  • devops tf pass-through verbs for the four operations
  • Zero-request --dry-run printing argv and directory
  • Removal of the wrapper's -o, -v, -p, -u aliases

Proposed design

Problem statement

The devops tf wrapper declares typed short options -o, -v, -p and -u that collide with tofu single-dash flags, so -out=FILE parses as -o ut=FILE. The wrapper also has no import, state, show or force-unlock verbs. This change removes the colliding short aliases, adds thin pass-through verbs, and adds a zero-request --dry-run that prints the tofu argv and the directory.

Acceptance criteria

Requirement: Plan pass-through

The devops tf plan command SHALL pass every argument after <directory> to tofu plan unchanged.

Scenario: Plan flags reach tofu

  • WHEN a test runs devops tf plan <dir> -out=x.plan -lock=false with a fake tofu executable
  • THEN the fake records the argv plan -out=x.plan -lock=false and the working directory <dir>.

Requirement: Short aliases removed

The tf subcommands MUST NOT declare -o, -v, -p or -u as wrapper short options.

Scenario: Removed alias is rejected

  • WHEN a test runs devops tf plan -o x.plan <dir>
  • THEN the command exits non-zero with an unknown option error and the fake records no tofu call.

Requirement: Import pass-through

The devops tf import command SHALL run tofu import in <directory> and forward every remaining argument unchanged.

Scenario: Import address and id reach tofu

  • WHEN a test runs devops tf import <dir> aws_instance.web i-123 with a fake tofu executable
  • THEN the fake records the argv import aws_instance.web i-123 and the working directory <dir>.

Requirement: State pass-through

The devops tf state command SHALL run tofu state in <directory> and forward every remaining argument unchanged.

Scenario: State list reaches tofu

  • WHEN a test runs devops tf state <dir> list with a fake tofu executable
  • THEN the fake records the argv state list and the working directory <dir>.

Requirement: Show pass-through

The devops tf show command SHALL run tofu show in <directory> and forward every remaining argument unchanged.

Scenario: Show JSON reaches tofu

  • WHEN a test runs devops tf show <dir> -json with a fake tofu executable
  • THEN the fake records the argv show -json and the working directory <dir>.

Requirement: Force-unlock pass-through

The devops tf force-unlock command SHALL run tofu force-unlock in <directory> and forward every remaining argument unchanged.

Scenario: Force-unlock id reaches tofu

  • WHEN a test runs devops tf force-unlock <dir> -force 123456 with a fake tofu executable
  • THEN the fake records the argv force-unlock -force 123456 and the working directory <dir>.

Requirement: Dry run

Each tf mirror verb SHALL print the full tofu argv and the directory on --dry-run and MUST NOT start tofu.

Scenario: Dry run starts no process

  • WHEN a test runs devops tf plan --dry-run <dir> -out=x.plan with a fake tofu executable
  • THEN the output contains tofu plan -out=x.plan and <dir>, and the fake records no process.

Requirement: Command documentation

The change SHALL document the new tf verbs and removed short aliases in docs/commands/tf.md and SHALL regenerate docs/CLI_REFERENCE.md from the command tree.

Scenario: Documentation check

  • WHEN the pull request updates the command tree and docs/commands/tf.md
  • THEN the docs row of Static Analysis passes with no generated-document diff for docs/CLI_REFERENCE.md, and docs/commands/tf.md shows import, state, show and force-unlock.

Existing Tool Considered

OpenTofu (https://github.com/opentofu/opentofu) is already in use. It supplies the engine and the import, state, show and force-unlock operations, and it accepts the single-dash flags that must reach it unchanged. It lacks the devops CLI pass-through verbs, the zero-request --dry-run that prints the argv and directory, the removal of the wrapper's colliding short options -o, -v, -p and -u, and the devops pacing and agent-refusal behaviour; Terragrunt adds no zero-request dry run, pacing or agent refusal. The issue records about 1.2M tokens for this pass-through part, about 50k tokens a month to keep, and about 200k tokens for each break; the full plan is 3 days in 3 PRs.

Key questions

  • How should devops tf separate wrapper options from tofu flags?: Keep <directory> as the first positional argument and forward every token after it to tofu unchanged. Declare wrapper options such as --dry-run before <directory>. (best practice) [sources: docs/commands/tf.md]
    • Chosen: Directory boundary. The issue example puts <dir> before -out=x.plan -lock=false, and the existing command shape is [OPTIONS] <directory>.
    • Rejected: Unknown options anywhere. It would consume or reject tokens that must reach tofu.
    • Rejected: Explicit -- separator. The issue example needs no separator, and the directory already gives the boundary.
  • Which typed options should the change remove?: Remove only the short aliases -o, -v, -p and -u named in the issue. Keep the long options that docs/commands/tf.md already declares before <directory>. (best practice) [sources: docs/commands/tf.md]
    • Chosen: Remove named short aliases only. The issue names these four aliases as the collision and says no shim.
    • Rejected: Remove all typed tofu options. It goes beyond the issue and removes documented long options.
    • Rejected: Keep the aliases and translate them. The issue rejects a shim and the aliases still collide.
  • What do the new import, state, show and force-unlock verbs do?: Each is a thin subcommand that takes <directory> first, runs tofu <verb> in that directory, and forwards every remaining token unchanged. (best practice) [sources: docs/commands/tf.md]
    • Chosen: Thin pass-through subcommands. It matches the mirror-verb design and the existing <directory> argument shape.
    • Rejected: Typed wrapper options for each verb. It adds code and can collide with tofu flags.
    • Rejected: One generic devops tf run verb. The issue asks for named verbs that mirror tofu.
  • What must --dry-run print and do?: It prints the full tofu argv and the working directory and starts no tofu process. A test with a fake tofu asserts that the fake records no call. (best practice) [sources: docs/commands/tf.md, CONTEXT.md]
    • Chosen: Print argv and directory, run nothing. It matches the issue and the project definition that a dry run makes no request.
    • Rejected: Run tofu plan with an extra flag. It still starts tofu and can make provider or state requests.
    • Rejected: Print only the command name. It does not show the directory or the forwarded flags.
  • How are the tf command documents kept correct?: Update docs/commands/tf.md in the pull request and regenerate docs/CLI_REFERENCE.md from the command tree. The docs row of Static Analysis refuses a generated reference that differs from generator output. (best practice) [sources: CONTEXT.md, docs/commands/tf.md]
    • Chosen: Update the guide and regenerate the reference. The issue requires both, and CONTEXT says nobody edits a generated document by hand.
    • Rejected: Edit only the generated reference by hand. The docs row refuses a file that is not generator output.
    • Rejected: Skip the command guide. The issue requires docs/commands/tf.md to be updated.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 13, 2026
  2. added
    type/feature
    status/new
    value/medium
    effort/medium
    on Nov 13, 2026
  3. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
    • Scope: none. The title has the scope tf, and .github/labels.yml declares no scope/tf label. Add the label to the file to give the scope to this item.
    • Related: fix(cli): a short flag never means another tool option #5229, which asks for a different change. Both address short-flag collisions in the tf wrapper, but #5229 fixes collisions across all tools while the candidate is tf-specific and also adds four new mirror verbs.
  4. added
    priority/p2-medium
    on Nov 13, 2026
  5. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found OpenTofu itself — the tool the issue names as doing "all of the work" — plus wrapper projects such as Terragrunt. OpenTofu supplies the engine and the state/import/show/force-unlock operations and accepts the single-dash flags that must reach it unchanged, so the pass-through work is largely covered by a tool already in use. It does not cover the devops CLI side of the need: the thin mirror verbs, the removal of the typed short options that collide with tofu flags, or a --dry-run that prints the argv and sends no request, and no wrapper project adds those either.

    The repository already uses this tool.

    Tool: opentofu/opentofu (https://github.com/opentofu/opentofu)

    • License: MPL-2.0
    • Last activity: 2026-11-16
    • Maintained: yes

    Covers:

    • OpenTofu is the IaC engine that performs the plan/apply and state work the mirror verbs forward
    • It provides the import, state, show and force-unlock operations the issue wants to expose
    • It accepts the tofu flags (e.g. -out=FILE, -lock=false) that must reach it unchanged

    Lacks:

    • No devops CLI pass-through verbs; the thin mirror verbs must still be written in the wrapper
    • No --dry-run that prints the tofu argv and the directory while sending no request
    • No devops pacing or agent-refusal behaviour
    • It does not resolve the collision of the wrapper's typed short options (-o, -v, -p, -u) with tofu single-dash flags
    • Terragrunt, the other wrapper found, adds orchestration but no zero-request dry run, pacing or agent refusal

    Tools considered:

    Searches run:

    • OpenTofu CLI wrapper pass-through arguments terraform dry-run argv, results: 5
    • tofu wrapper tool import state show force-unlock subcommands CLI, results: 5
    • terragrunt wrapper around OpenTofu passes arguments through dry run, results: 5
    • open source CLI wrapper terraform opentofu subcommands import state show force-unlock pass-through flags, results: 5
    • OpenTofu, results: 5
    • terragrunt, results: 5
    • OpenTofu commands import state show force-unlock documentation, results: 5
    • terragrunt dry-run no requests plan print arguments, results: 5
    • opentofu docs cli commands import state show force-unlock, results: 5
    • opentofu state force-unlock import, results: 5

    Sources:

    Checked on 2026-11-16. A person decides what this means for the item. The check changes no label and closes no issue.

  6. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  7. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 1774ebf (see proposed design in issue body).

  8. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 25, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 25, 2026
  10. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor
  11. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 04:21 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions