This article follows the official documentation. We haven’t tested this tool for a hands-on review.
When a coding agent works on cloud infrastructure, the Pulumi CLI lets it inspect a planned change before applying it. Developers define infrastructure in code with Pulumi, which groups its state and configuration into a stack, an independent instance such as a development or production environment. The agent can run a preview and read structured output. An operator or authorized agent uses a separate update command to make the change.
Pulumi documents features for agents, including npx pulumi for running CLI commands and --json for structured output. These features let an agent review an infrastructure change in an existing project. The agent still needs access to the Pulumi backend and the credentials required by the target cloud provider.
Prepare the shell
From a Pulumi project directory, run the CLI through npx:
npx pulumi version
Pulumi documents npx pulumi for running CLI commands. The command above checks that the CLI runs in the current shell; it does not preview or change infrastructure. See Pulumi’s AI and infrastructure documentation for its agent-oriented CLI features.
Before previewing, sign in to the Pulumi backend that stores the stack and make sure the shell has the cloud-provider credentials the project needs. Configure the agent to use credentials supplied outside its prompt, such as through its execution environment. Do not paste access tokens or cloud secrets into the prompt.
Preview an existing stack
Ask the agent to inspect the selected stack and generate a JSON preview:
npx pulumi stack
npx pulumi preview --json
The first command identifies the selected stack. If no stack is selected and the command fails, stop and ask which existing stack to use rather than guessing an environment. The second command evaluates the project and requests structured JSON output describing the changes Pulumi plans for the stack. The agent can inspect those resource changes and report what it found.
For example, an agent prompt could say:
In this Pulumi project, identify the selected stack and run a JSON preview. Summarize the planned resource changes and flag anything that would delete or replace a resource. Do not apply the update.
When the CLI creates a preview, it contacts the Pulumi backend and, depending on the project, cloud-provider APIs. The CLI does not apply the planned infrastructure changes. The agent should describe the preview output without assuming it is empty or that a particular resource will change.
Keep preview and update separate
The agent and reviewer can examine the plan before an operator or authorized agent runs an update to make the planned changes. For example:
npx pulumi up
That command deploys the changes and can modify cloud resources. Decide separately whether to run it; generating or summarizing a preview does not make that decision. Pulumi’s documentation describes agents as able to write, preview, and deploy infrastructure, but the agent’s configuration and permissions determine which actions it can take.
The CLI also has commands that change stack state, so anyone with shell access has more authority than read-only inspection requires. For a review task, tell the agent to stop after pulumi preview. Do not grant deployment credentials unless the task requires an update.