tfctl CLI command reference
This topic provides an overview of all tfctl CLI commands. Each command reference includes documentation with usage examples, arguments, and options.
The tfctl CLI provides three levels of abstraction for interacting with HCP Terraform and Terraform Enterprise:
- High-level commands, such as
tfctl get workspacesandtfctl run start, for common operations - Generic commands, such as
tfctl createandtfctl get, that work with any resource type - Direct API access using the
tfctl apicommand group for operations not covered by convenience commands
This reference documents all available commands, their options, and usage patterns.
Command categories
The tfctl command includes subgroups for different operations.
Top-level commands
The create and get commands allow you to create and get HCP Terraform resources.
tfctl create: Create resourcestfctl get: Get or list resources
Authentication
The tfctl auth command group allows you to authenticate tfctl with HCP Terraform or Terraform Enterprise.
tfctl auth: Manage authentication with HCP Terraformtfctl auth login: Authenticate with HCP Terraformtfctl auth status: Check authentication status
Harness management
The tfctl harness command group allows you to manage AI agent harness contexts.
tfctl harness: Manage harness installationstfctl harness context: Display harness contexttfctl harness exec: Run a child command with session-scoped delete permissionstfctl harness install: Install harness components
Profile configuration
The tfctl profile command group allows you to manage configuration profiles to support multiple organizations and instances of HCP Terraform and Terraform Enterprise.
tfctl profile: Manage profilestfctl profile display: Display current profiletfctl profile get: Get profile valuetfctl profile profiles: Manage configuration profilestfctl profile profiles activate: Activate a profiletfctl profile profiles create: Create a profiletfctl profile profiles delete: Delete a profiletfctl profile profiles list: List profilestfctl profile profiles rename: Rename a profile
tfctl profile set: Set profile valuetfctl profile unset: Unset profile value
Run management
The tfctl run command group allows you to manage Terraform runs on your workspaces.
tfctl run: Manage Terraform runstfctl run start: Start a new runtfctl run status: Check run status
Variable management
The tfctl variable command group allows you to manage variables in workspaces and variable sets.
tfctl variable: Manage workspace variablestfctl variable import: Import variables
API operations
The tfctl api command group supports full access to HCP Terraform's API.
tfctl api: Direct API operationstfctl api schema: Search and inspect API operationstfctl api schema get: Show API operation schematfctl api schema search: Search API operations
Global flags
All tfctl commands support global flags that control CLI behavior, output formatting, and execution mode. For detailed information about each flag, including data types and examples, refer to the Global flags reference.
Pagination
Commands that list resources, such as tfctl get and tfctl api, support pagination options to control how results are returned.
Pagination options
Operations that paginate their output support the following flags:
--page-size=NUMBER: Number of results per page. The default varies by resource type and is determined by the API.--page-number=NUMBER: Page number to fetch. Page numbers begin at1. Defaults to1.--all: Automatically fetch all pages. When using--all, the command fetches the first page, follows pagination links in the response, and continues until all pages are retrieved. Limited to 2000 records maximum.
Behavior
By default, commands return a single page of results with an API-determined page size. Use --page-size to control how many records per page, and --page-number to fetch a specific page.
When you use the --all flag, tfctl fetches all available pages sequentially until it reaches 2000 records or no more results remain, whichever comes first. Note that --page-size and --page-number are ignored when --all is set.
Examples
List workspaces with custom page size:
$ tfctl get workspaces --page-size 50
Fetch a specific page:
$ tfctl get workspaces --page-number 2
Automatically fetch all pages:
$ tfctl get workspaces --all
Exit codes
The tfctl CLI uses the following exit codes:
| Exit code | Description | Solution |
|---|---|---|
0 | Success | — |
1 | Usage error | Read tfctl <cmd> --help |
2 | HCP Terraform not found or authorization error | Verify URL or your ID |
3 | API authorization error | Run tfctl auth login |
4 | Network error | Check connectivity |
5 | API server error persists | Try again later |
6 | Underlying error detected | Varies depending on error condition, for example, run tfctl auth status when not authenticated |
| 130 | Canceled (Ctrl-C) | — |