stub-generator

Generate minimal code stubs from Python type stubs or test imports.

Updated Mar 4, 2026
One-click install
npx skills add https://github.com/djpTester44/iocane --skill stub-generator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stub-generator
Source: https://github.com/djpTester44/iocane/tree/main/%7B%7Bcookiecutter.framework_folder%7D%7D/skills/stub-generator
Command: npx skills add https://github.com/djpTester44/iocane --skill stub-generator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill automates the creation of placeholder code (stubs) for classes, functions, and protocols, enabling developers to focus on writing tests first, even when the implementation code doesn't exist yet.

Core Features & Use Cases

  • Protocol-driven Stub Generation: Create implementation skeletons directly from .pyi interface definitions.
  • Test Import Analysis: Automatically identify and generate stubs for missing imports found during test collection, resolving ImportError issues in TDD workflows.
  • Use Case: When starting a new feature, write your tests first. If a test fails because the function or class it needs hasn't been written, use this Skill to generate a basic stub, allowing the test to run and fail on an assertion rather than an import error.

Quick Start

Generate stubs for the missing imports in the file 'tests/test_user_service.py'.

Frequently Asked Questions about stub-generator

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

FAQPage Schema
How do I generate Python code stubs from test file imports to fix ImportError during TDD?

To generate Python code stubs from test file imports, the tool analyzes your test collection, identifies missing classes and functions, and creates placeholder code with NotImplementedError or pass bodies to resolve ImportError issues in TDD workflows.

What is the best way to create implementation skeletons from .pyi type stubs?

Creating implementation skeletons from .pyi type stubs involves using a protocol-driven generation process that reads your Python interface definitions and outputs minimal class and function placeholders to start your development.

Why does my test fail with ImportError before running assertions in test-driven development?

Your test fails with ImportError because the implementation code for the imported classes or functions does not exist yet. You can resolve this TDD red phase problem by generating minimal placeholder stubs for the missing modules.

Can I use this stub generation approach for legacy Python codebases?

Yes, you can use stub generation for legacy Python codebases. The tool supports legacy TDD workflows by analyzing existing test file imports and automatically generating the missing placeholder code required to run your tests.

What do generated Python code stubs contain for unimplemented functions and protocols?

Generated Python code stubs contain minimal placeholder definitions for functions, classes, and protocols, with bodies utilizing either a pass statement or raising NotImplementedError to allow tests to run and fail on assertions.

Do I need Python type stub files to generate code skeletons?

You do not strictly need Python type stub files to generate code skeletons. The tool supports both .pyi-first development and analyzing test file imports directly to create the necessary placeholder code.