Terraform Enterprise and HCP Terraform CLI (tfctl)
Use tfctl to manage your HCP Terraform and Terraform Enterprise organizations. Integrate with AI agents to automate Terraform management.
The tfctl CLI is a command-line tool for managing HCP Terraform and Terraform Enterprise resources. It simplifies authentication, workspace management, and API interactions, allowing you to integrate HCP Terraform and Terraform Enterprise into your automation pipelines and development workflows. Integrate tfctl with your AI agent to inspect and use the HCP Terraform or Terraform Enterprise API on your behalf.
How does tfctl work?
tfctl wraps the HCP Terraform and Terraform Enterprise API to provide both high-level convenience commands and direct API access. When you run a tfctl command, it authenticates using a token stored in your active profile. Then it resolves context from your profile and existing Terraform configuration, if any. Next tfctl makes API calls on your behalf, handling authentication, request formatting, and response parsing.
Command levels
The tfctl CLI provides three levels of abstraction:
- High-level commands such as
tfctl variable importandtfctl run startfor common operations. - Generic commands such as
tfctl createandtfctl getthat work with any resource type. - Direct API access using the
tfctl apicommand group for operations not covered by convenience commands.
Why tfctl?
tfctl streamlines authentication to Terraform APIs by handling token generation through your browser or reuses existing Terraform CLI tokens. The CLI provides built-in skills for coding assistants such as Claude Code, GitHub Copilot, and IBM Bob, allowing you to manage Terraform workloads with your agent through full access to the HCP Terraform or Terraform Enterprise API. You can manage multiple organizations using tfctl's profile-based configuration. For example, you can create separate profiles for development, staging, and production environments.
Get started
Complete these steps to start using tfctl:
Install the CLI on your system. Refer to Install tfctl for instructions.
Authenticate tfctl to your HCP Terraform account. Refer to Authenticate with HCP Terraform for instructions.
Configure your environment by setting your default organization. Replace
<ORGANIZATION_NAME>with the name of your HCP Terraform or Terraform Enterprise organization.$ tfctl profile set default_organization <ORGANIZATION_NAME>Test your configuration by listing workspaces for your organization.
$ tfctl get workspaces
AI agent integration
The tfctl CLI is designed to work with AI agents such as Claude, GitHub Copilot, IBM Bob, and others. When you install the tfctl skill for your agent, you can use it to manage HCP Terraform resources with natural language, create automation for complex workflows across workspaces, organizations, and instances of HCP Terraform or Terraform Enterprise, and provide context-aware suggestions for Terraform operations.
The skill provides your agent with documentation and examples, a requirement to get confirmation for destructive operations, and structured output for parsing and decision-making.
To enable AI agent integration, refer to Install AI agent skill.
Next steps
- For example use cases, review the examples for tfctl.
- To learn more about tfctl commands, refer to the CLI reference documentation.
- To learn how to manage tfctl configuration profiles, refer to tfctl profiles.
Contributing
The tfctl CLI is open source. To contribute to the project or build from source, visit the tfctl-cli repository on GitHub. The repository includes detailed developer documentation, contribution guidelines, and instructions for building from source.