Solid template for writing pytest tests against Typer CLI apps. You get ready-made fixtures for temp storage and sample data, patterns for handling confirmations (the y/n/--force dance), and a breakdown by command type (CRUD operations). The AAA structure examples are clean, and it covers the annoying edge cases like invalid IDs and empty states. Really shines when you're adding test coverage to an existing CLI or want consistent patterns across commands. The CliRunner examples with input strings for confirmations save you from hunting through docs. If you're building task managers, note apps, or any stateful CLI tool, this gets you from zero to decent coverage fast.

GitHub stars
1.3K
last updated
Jun 8, 2026

Install

$ npx -y skills add https-deeplearning-ai/sc-agent-skills-files --skill generating-cli-tests --agent claude-code

Installs into .claude/skills of the current project.

Files

Generating CLI Tests

Patterns for generating tests for Typer CLI commands.

Workflow

  1. Identify command type (Create/Read/Update/Delete/Bulk)
  2. Ensure fixtures exist in conftest.py
  3. Write tests using scenarios below
  4. Run tests to verify

Fixtures (conftest.py)

import json
import pytest
from typer.testing import CliRunner


@pytest.fixture
def runner():
    """CLI test runner."""
    return CliRunner()


@pytest.fixture
def temp_storage(tmp_path, monkeypatch):
    """Empty storage for testing."""
    storage_dir = tmp_path / ".task"
    storage_dir.mkdir()
    storage_file = storage_dir / "tasks.json"
    storage_file.write_text(json.dumps({"version": 1, "tasks": []}))
    monkeypatch.setenv("TASK_STORAGE_PATH", str(storage_file))
    return storage_file

Sponsors

Details

Repository
github.com/https-deeplearning-ai/sc-agent-skills-files
Categories
Backend & APIs, Testing & QA, AI & Agent Building, Python, CLI & Terminal
First seen
Jun 11, 2026

More from https-deeplearning-ai/sc-agent-skills-files

All 4
1huangjia2019 avatardoc-writinghuangjia2019/claude-code-engineeringGenerate API documentation from a route manifest. Use when you have a list of discovered routes and need to produce markdown documentation.0skills.sh installs
2hypnguyen1209 avatarexploit-developmenthypnguyen1209/offensive-claudePoC development, payload crafting, shellcode generation, ROP chains, heap exploitation, bypass techniques for modern mitigations (ASLR, DEP, CFI, stack canaries0skills.sh installs
3hypnguyen1209 avatarinitial-accesshypnguyen1209/offensive-claudeModern initial access techniques — phishing, payload delivery, HTML smuggling, ISO/IMG bypass, supply chain attacks, credential stuffing, exposed service exploi0skills.sh installs
4hypnguyen1209 avatarshellcode-devhypnguyen1209/offensive-claudeShellcode development — PIC techniques, PEB walking, API hashing, null-byte avoidance, encoders, loaders, PE-to-shellcode conversion, cross-platform shellcode0skills.sh installs
5hypnguyen1209 avatarvulnerability-analysishypnguyen1209/offensive-claudeExpert-level source code security auditing — taint analysis, memory safety, injection classes, auth flaws, crypto weaknesses, concurrency bugs, supply chain ris0skills.sh installs
6jdrhyne avatargongjdrhyne/agent-skillsGong API for searching calls, transcripts, and conversation intelligence. Use when working with Gong call recordings, sales conversations, transcripts, meeting 0skills.sh installs