Use generated CLIs with AI agents

View as Markdown

The Postman CLI Generator creates command-line interfaces specifically designed for AI agent integration. These generated CLIs come with AI agent skills that provide structured context, enabling agents to understand and interact with your APIs autonomously.

AI agents increasingly interact with APIs through command-line interfaces because CLIs provide the following advantages for agent integration:

  • Structured command patterns that agents can learn and replicate.
  • Built-in help documentation that agents can reference dynamically.
  • Consistent input/output formats that simplify parsing and automation.
  • Contextual skills that guide agent behavior without overwhelming context windows.

The CLI generator bridges the gap between your API and AI agent by creating purpose-built tools that agents can understand and use effectively.

Get started with AI agents

To use generated CLIs with AI agents, do the following:

  1. Generate your CLI from a collection or specification in Postman.
  2. Download and build the CLI following the setup instructions.
  3. Configure authentication using the setup-auth command.
  4. Provide the skills directory to your AI agent workspace.
  5. Test basic commands to ensure proper authentication and connectivity.

Skills file structure

Each skill file contains structured information optimized for AI consumption:

  • Command syntax with all required and optional parameters.
  • Authentication requirements and setup instructions.
  • Request/response examples with realistic data.
  • Error handling guidance for common failure scenarios.
  • Related commands for workflow chaining.

Skills are automatically generated based on your API specification, ensuring they stay synchronized with your actual API capabilities.

AI agent skills in action

When you generate a CLI, Postman automatically creates skills, which are structured Markdown files that help AI agents understand how to use each command. These skills provide context without overwhelming the agent’s working memory.

Hierarchical skill organization

Skills are organized at the service level rather than individual commands to optimize context window usage. The following is an example of how skills are structured for a music app API:

skills/
├── albums/ # Service-level skill
├── artists/ # Service-level skill
├── tracks/ # Service-level skill
└── playlists/ # Service-level skill

Dynamic skill loading

Instead of loading all available commands upfront, agents can:

  1. Load service-level skills to understand available API categories.
  2. Dynamically fetch command details when needed for specific operations.
  3. Chain multiple commands together to complete complex workflows.

This approach prevents context overflow while maintaining full API access.

For an API with 100+ commands, agents only load relevant skills as needed, keeping context focused and manageable.

When working with generated CLIs, AI agents leverage the skills to do the following:

  • Load skills incrementally to manage context window effectively.
  • Validate authentication before attempting API operations.
  • Handle errors gracefully using the troubleshooting guidance in skills.
  • Chain commands logically using output from one command as input to another.
  • Respect rate limits and API constraints documented in skills.

Agent workflow example

The following is an example of how an AI agent might use a generated music app CLI to create a playlist.

Skill discovery

The agent loads service-level skills to understand available operations:

  • users — User profile and preferences
  • tracks — Track information and top tracks
  • playlists — Playlist creation and management

Command execution

The agent uses the output from each command to inform the next steps, such as using the user ID from the profile command to create a playlist and then adding tracks based on the top tracks command.

The agent combines outputs from multiple commands to complete complex tasks like playlist creation with personalized track selection.

$# Get current user profile
$mymusicapp-cli users get-current-users-profile
$
$# Get user's top tracks
>mymusicapp-cli users get-users-top-artists-and-tracks --type tracks --limit 10
>
># Create new playlist
>mymusicapp-cli playlists create-playlist --user-id {user-id} --body '{
> "name": "AI Generated Playlist",
> "description": "Top tracks playlist"
>}'
>
># Add tracks to playlist
>mymusicapp-cli playlists add-tracks-to-playlist --playlist-id {playlist-id} --body '{
> "uris": ["mymusicapp:track:...", "mymusicapp:track:..."]
>}'

Agent integration examples

Popular AI agents that work well with generated CLIs include:

  • Claude Code — Can read skills and run CLI commands autonomously.
  • Cursor — Integrates with workspace skills for code assistance.
  • Custom LLM workflows — Use skills as structured prompts for API automation.
  • GitHub Copilot — Leverages skills for CLI command suggestions.

The generated skills follow standard conventions that most AI agents can interpret and use effectively.