Skip to content

TsukiNi22/ai-utils / skills/python/python-project

python-project

Verified

Set up a new Python project in Tsukini's way - a script, an application in the layout of his MAGIC project (src/main.py + app.py + const.py, Class/, tool/, data/, requirements.txt) or an installable package (src layout, __init__.py with the version and the public API, __main__.py, const.py with frozen dataclasses, exception.py with error codes, main() returning the exit code, pyproject.toml with a console command, pytest tests) - generated by scripts/new_project.py with the Xartania headers, then README / license / CI / git with the other skills. Use whenever the user wants to create, bootstrap or scaffold a Python project, package, tool or script project.

templates/package/main.py

View on GitHub
{{HEADER:main.py:Main of {{PACKAGE}}: arguments, run, exit code}}

##### Import #####
# Import that can't be in the try
from .const import RETURN, ERROR, VALUES
from .exception import ProjectError
from sys import argv, stderr

# Import that can be checked
try:
    import argparse # Used for the arguments
except ImportError as e:
    stderr.write(f"Import Error ({__file__}): {e}\n")
    raise SystemExit(255)

##### Tools #####
def parse(arguments: list[str]) -> argparse.Namespace:
    parser = argparse.ArgumentParser(prog=VALUES.NAME, description="{{DESC}}")
    parser.add_argument("-v", "--version", action="version", version=f"{VALUES.NAME} {VALUES.VERSION}")
    return parser.parse_args(arguments)

##### Program #####
def main(arguments: list[str] | None = None) -> int:
    # Entry point (console script, python -m), returns the exit code
    args = parse(argv[1:] if arguments is None else arguments)
    try:
        pass # The program
    except ProjectError as e:
        stderr.write(e.formated() + "\n")
        return e.code
    except KeyboardInterrupt:
        return ERROR.LOCAL
    return RETURN.OK
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 319kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 319kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 319kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall