TsukiNi22/ai-utils / skills/python/python-project
python-project
UnverifiedSet 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.1 KB |
| requires.txt | markdown | 71 B |
| scripts/new_project.pyexecutable | script | 5.7 KB |
| templates/app/app.py | script | 478 B |
| templates/app/main.py | script | 661 B |
| templates/common/const.py | script | 1.6 KB |
| templates/common/gitignore | other | 184 B |
| templates/common/script.py | script | 712 B |
| templates/package/__init__.py | script | 365 B |
| templates/package/__main__.py | script | 192 B |
| templates/package/exception.py | script | 836 B |
| templates/package/main.py | script | 1.1 KB |
| templates/package/pyproject.toml | manifest | 560 B |
| templates/package/test_main.py | script | 680 B |
scripts/new_project.py
View on GitHub"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
██╗ ██╗ █████╗ ██████╗ ████████╗ █████╗ ███╗ ██╗██╗ █████╗
╚██╗██╔╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗████╗ ██║██║██╔══██╗
╚███╔╝ ███████║██████╔╝ ██║ ███████║██╔██╗ ██║██║███████║
██╔██╗ ██╔══██║██╔══██╗ ██║ ██╔══██║██║╚██╗██║██║██╔══██║
██╔╝ ██╗██║ ██║██║ ██║ ██║ ██║ ██║██║ ╚████║██║██║ ██║
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝
Edition:
## 06/10/2026 by Tsukini
File Name:
## new_project.py
File Description:
## Create a Python project in the user's layout: script, application (MAGIC) or installable package
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
##### Import #####
# Import that can't be in the try
from sys import argv, exit, stderr
# Import that can be checked
try:
from importlib.util import spec_from_file_location, module_from_spec # Used to load header.py (cpp-class)
from datetime import date # Used for the headers
from pathlib import Path # Used to create the files
import argparse # Used for the arguments
import re # Used for the placeholders
except ImportError as e:
stderr.write(f"Import Error ({__file__}): {e}\n")
exit(255)
# Check if the program is call and not imported
if __name__ != "__main__":
stderr.write(f"The {__file__} can only be executed and not imported!\n")
exit(255)
##### Const #####
SKILL = Path(__file__).resolve().parent.parent
TEMPLATES = SKILL / "templates"
HEADER_SCRIPTS = [SKILL.parent / "cpp-class" / "scripts" / "header.py", # skills side by side (setup.sh --copy, claude.ai)
SKILL.parent.parent / "cpp" / "cpp-class" / "scripts" / "header.py"] # category folders (the repository, a plugin)
HEADER_SCRIPT = next((path for path in HEADER_SCRIPTS if path.is_file()), None)
LAYOUTS = { # kind -> [(template, destination)]
"script": [("common/script.py", "{{NAME}}.py"), ("common/const.py", "const.py"), ("common/gitignore", ".gitignore")],
"app": [("app/main.py", "src/main.py"), ("app/app.py", "src/app.py"), ("common/const.py", "src/const.py"), ("common/gitignore", ".gitignore")],
"package": [("package/__init__.py", "src/{{PACKAGE}}/__init__.py"), ("package/__main__.py", "src/{{PACKAGE}}/__main__.py"),
("common/const.py", "src/{{PACKAGE}}/const.py"), ("package/exception.py", "src/{{PACKAGE}}/exception.py"),
("package/main.py", "src/{{PACKAGE}}/main.py"), ("package/pyproject.toml", "pyproject.toml"), ("package/test_main.py", "tests/test_main.py"),
("common/gitignore", ".gitignore")],
}
FOLDERS = {"script": [], "app": ["src/Class", "src/tool", "data"], "package": []} # empty folders of the layout (with a .gitkeep)
##### Tools #####
def load_header() -> object:
if HEADER_SCRIPT is None:
stderr.write("Error: header.py of the cpp-class skill not found (install cpp-class next to this skill)\n")
exit(1)
spec = spec_from_file_location("header", HEADER_SCRIPT)
module = module_from_spec(spec)
spec.loader.exec_module(module)
return module
def fill(text: str, values: dict[str, str], header: object, banner: str) -> str:
# {{HEADER:<file>:<description>}} first (it can contain the other placeholders), then {{KEY}}
for key, value in values.items():
text = text.replace("{{" + key + "}}", value)
return re.sub(r"\{\{HEADER:([^:}]+):([^}]*)\}\}", lambda m: header.header(m[1], banner, m[2] or None, "Tsukini", date.today().strftime("%d/%m/%Y"), "py"), text)
##### Program #####
parser = argparse.ArgumentParser(description="Create a Python project in the user's layout")
parser.add_argument("name", help="project name (folder, distribution / command name)")
parser.add_argument("--kind", choices=list(LAYOUTS), default="package", help="script | app (MAGIC layout) | package (installable, pyproject)")
parser.add_argument("--dir", default=".", help="parent folder")
parser.add_argument("--desc", default="...", help="one line description")
parser.add_argument("--python", default="3.12", help="minimal Python version")
parser.add_argument("--version", default="1.0.0", help="first version")
parser.add_argument("--banner", default="xartania", help="banner of the headers: xartania | none | <text>")
args = parser.parse_args(argv[1:])
root = Path(args.dir) / args.name
if root.exists() and any(root.iterdir()):
stderr.write(f"Error: {root} exists and is not empty\n")
exit(1)
values = {"NAME": args.name, "PACKAGE": re.sub(r"\W", "_", args.name.lower()), "DESC": args.desc, "PYTHON": args.python, "VERSION": args.version}
header = load_header()
for template, destination in LAYOUTS[args.kind]:
path = root / fill(destination, values, header, args.banner)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(fill((TEMPLATES / template).read_text(encoding="utf-8"), values, header, args.banner), encoding="utf-8")
print(f"created {path}")
for folder in FOLDERS[args.kind]:
(root / folder).mkdir(parents=True, exist_ok=True)
(root / folder / ".gitkeep").touch()
(root / "README.md").write_text(f"# {args.name}\n\n{args.desc}\n", encoding="utf-8")
if args.kind == "app":
(root / "requirements.txt").write_text("", encoding="utf-8")
exit(0)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| 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: 196k | Updated | Claude CodeCodex | Verified | Install |