cli-packaging-patterns

Design pure Python CLI installation and execution patterns with hatchling and uv.

10|11|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/microsoft/amplifier-bundle-skills --skill cli-packaging-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cli-packaging-patterns
Source: https://github.com/microsoft/amplifier-bundle-skills/tree/main/skills/cli-packaging-patterns
Command: npx skills add https://github.com/microsoft/amplifier-bundle-skills --skill cli-packaging-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you package and distribute a pure Python CLI so it installs cleanly from a git URL, runs reliably from the command line or as a module, and supports predictable configuration without manual setup.

Core Features & Use Cases

  • One-line installation: Set up a CLI with uv tool install and hatchling-backed project scripts.
  • Dual entry points: Make both the installed command and python -m invocation work consistently.
  • Default-action subcommands: Design the bare command to behave like the primary serve action while still supporting explicit subcommands.
  • Three-tier config resolution: Resolve settings in the order CLI flags, config file, then hardcoded defaults.
  • Post-install workflow guidance: Choose the right first-run pattern for init, login, configure, or no setup at all.
  • Use case: A team building an internal automation CLI can publish it from git, keep startup behavior consistent, and avoid brittle installation steps.

Quick Start

Use the cli-packaging-patterns skill to design a pure Python CLI that installs with uv, exposes a reliable command entry point, and resolves configuration from flags, files, and defaults.

Frequently Asked Questions about cli-packaging-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I package a Python CLI for one-line installation from a git URL?

Package a pure Python CLI for git-based installation by configuring hatchling scripts and ensuring compatibility with uv tool install, enabling a single command to deploy the tool reliably without manual setup steps.

How do I make a Python CLI run consistently as both an installed command and a module?

Make a Python CLI run consistently by defining dual entry points: a hatchling-backed script for the installed command and a __main__ entry point for python -m invocation, ensuring both paths dispatch identically through argparse.

What is the best way to structure argparse subcommands so the bare command defaults to the primary action?

Structure argparse dispatch to make the bare command behave like the primary serve action by setting default subcommand behavior, allowing users to run the tool with no arguments for the main task while still supporting explicit subcommands.

How does three-tier configuration resolution work for a Python CLI?

Three-tier configuration resolution for a Python CLI prioritizes settings in the order of CLI flags, then a config file, and finally hardcoded defaults, ensuring predictable runtime behavior without complex manual overrides.

Does uv tool install work with hatchling for pure Python CLI projects?

Yes, uv tool install works with hatchling by using hatchling-backed project scripts to define the entry point, allowing a pure Python CLI to install cleanly and execute directly from the command line.

How do I choose the right first-run pattern for a Python CLI after installation?

Choose the right first-run pattern for a Python CLI by evaluating post-install workflow needs—selecting init, login, configure, or no setup at all—to guide users immediately after a clean installation.