typer-cli-patterns
Skill0 starsChanged 7 months agoApache-2.0View on GitHub
Guardrail for Typer-based Python control-plane CLIs that keep handlers thin, deterministic, testable, and separated from runtime behavior.
In this repository57 other files it gives its agents.
- ai-app-integrationSkill
- anti-llm-frontend-designSkill
- aspnet-core-web-developmentSkill
- async-python-patternsSkill
- browser-game-foundationsSkill
- browser-local-qaSkill
- build-mcp-server-sdk-v2Skill
- canva-design-opsSkill
- check-completionSkill
- cli-tool-creatorSkill
- cloudflare-agents-mcpSkill
- cloudflare-durable-objectsSkill
- cloudflare-workers-platformSkill
- deployment-preview-workflowsSkill
- docx-document-artifactsSkill
- durable-workflow-orchestrationSkill
- dynamic-og-imagesSkill
- eval-auditSkill
- evaluate-ragSkill
- figma-design-to-code-rulesSkill
- fine-tuningSkill
- frontend-product-builderSkill
- game-asset-pipeline-expansionSkill
- game-ui-playtestSkill
- generate-synthetic-dataSkill
- github-pr-ci-opsSkill
- gmail-inbox-opsSkill
- golden-datasetSkill
- huggingface-llm-trainerSkill
- javascript-monorepo-buildsSkill
- linear-issue-managementSkill
- media-generation-transcriptionSkill
- millrace-rs-contract-paritySkill
- minecraft-mod-qa-automationSkill
- notion-workspace-flowsSkill
- openai-docsSkill
- optimize-agentic-cliSkill
- pdf-artifact-workflowSkill
- phaser-2d-game-developmentSkill
- postgres-query-performanceSkill
- product-ui-polish-reviewSkill
- pydantic-v2-patternsSkill
- python-repo-refactoring-hygieneSkill
- rag-corpus-hygieneSkill
- react-next-performance-reviewSkill
- rust-best-practicesSkill
- shadcn-ui-compositionSkill
- skill-evaluation-harnessSkill
- tauri-desktopSkill
- tauri-mcp-cliSkill
- tauri-ptySkill
- tile-pixel-art-transitionsSkill
- train-sentence-transformersSkill
- using-dbt-for-analytics-engineeringSkill
- validate-evaluatorSkill
- visual-asset-pipelineSkill
- watchdog-file-watcher-patternsSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 40
Keep each handler thin: parse inputs, call one control-layer operation, render output, and exit.
- Distinctive: line 41
Keep reads pure and writes explicit.
- Distinctive: line 43
Keep machine output free of progress prose and nondeterministic field ordering.
- Very specific: line 50
Read commands such as status, queue, and config show must not mutate runtime state.
- Distinctive: line 76
Add tests using isolated temp state and representative control-layer results.
- Distinctive: line 77
Run help output and targeted CLI tests.
- Distinctive: line 88
Start with the changed command group.
- Very specific: line 95
Run targeted CLI tests plus a --help smoke check for changed commands.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Typer CLI Patterns
Purpose
Help agents build or refactor Typer command surfaces that wrap a runtime or control API without moving engine logic into CLI handlers. This skill is for Python control-plane CLIs with deterministic output, explicit exits, and focused tests.
Use When
- adding or changing Typer commands for status, start, stop, pause, resume, queue inspection, config, or task intake
- introducing shared flags such as
--json,--format,--detail,--timeout, or--verbose - refactoring CLI handlers that contain runtime logic, queue mutation, or output formatting sprawl
- adding tests for command success, validation, and failure behavior
Do Not Use When
- building a REPL, shell, TUI, or generic command runner
- using Click directly without Typer conventions
- the task is mostly runtime behavior and the CLI surface is unchanged
Quick Start
- Keep each handler thin: parse inputs, call one control-layer operation, render output, and exit.
- Keep reads pure and writes explicit.
- Standardize one structured output mode, usually
--jsonor--format json. - Keep machine output free of progress prose and nondeterministic field ordering.
- Validate user input before runtime mutation.
- Cover changed command groups with success and failure tests using Typer's runner or the repo's CLI test harness.
Operating Constraints
- Importing the CLI module must not start runtime loops, load mutable queues, or mutate config.
- Handlers should not reach directly into engine internals when a control API exists.
- Read commands such as
status,queue, andconfig showmust not mutate runtime state. - Mutating commands must call named control operations and make side effects explicit.
- Human output and JSON output must have stable shapes.
- User-facing errors should map to deterministic exit codes and concise messages.
- Help text should match the real command contract.
Inputs This Skill Expects
- CLI entry module or package.
- Underlying control/API surface called by the CLI.
- Target command list, changed verbs, or desired runtime operations.
- Current help output, tests, snapshots, and exit-code policy when available.
- Sample control-layer success and failure payloads.
Output Contract
- Provide a command tree or patch where handlers stay thin and deterministic.
- Name command-to-control mappings for changed commands.
- State read/write boundaries, output format policy, and exit behavior.
- Include focused tests for at least one success path and one failure or edge path per changed command group.
- Report help text or docs updates when the user-facing command surface changes.
Procedure
- Inspect CLI entrypoints, Typer app structure, imports, and control-layer operations.
- Map each command to exactly one control operation or one composed read path.
- Pull rendering into small deterministic helpers when handlers are getting noisy.
- Validate parameters and options before invoking mutating control calls.
- Implement JSON output with stable keys and human output with stable headings.
- Add tests using isolated temp state and representative control-layer results.
- Run help output and targeted CLI tests.
Pitfalls And Gotchas
- Letting Typer handlers become the runtime layer.
- Running side effects at import time.
- Mixing logs, progress, or prose into JSON output.
- Adding both
--jsonand--format jsonwithout a clear compatibility reason. - Making
statusorconfig showmutate state as a side effect. - Testing only the happy path and missing validation, missing config, or runtime-error mapping.
Progressive Disclosure
Start with the changed command group. Expand to shared renderers, exit-code policy, command grouping, or docs only when the current change crosses those surfaces. Keep runtime design in the control layer and CLI design in the command layer.
Verification Pattern
- Confirm CLI module import has no runtime side effects.
- Confirm each changed handler parses, calls control, renders, and exits without embedding engine logic.
- Confirm read commands are pure and write commands are explicit.
- Confirm JSON output parses and has stable keys.
- Run targeted CLI tests plus a
--helpsmoke check for changed commands.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

