moarch-py
A Python CLI that scaffolds feature-first FastAPI projects on uv, SQLAlchemy 2 (async), Alembic and Pydantic v2, with your conventions built in: layers, tests, Docker, CI, Ruff, mypy and an AI agent guide.
It is the FastAPI sibling of moarch for Flutter
and uses the same commands: init makes the project, create adds to it.
Install
uvx moarch-py init my-api # run once without installing
uv tool install moarch-py # or install the `moarch-py` command
It needs uv. Generated projects target Python 3.12+.
Quick start
moarch-py init shop-api # wizard: database + what to generate
cd shop-api
docker compose up -d db
uv run alembic upgrade head
uv run fastapi dev src/shop_api/main.py # http://localhost:8000/docs
moarch-py create feature orders # model, schemas, repository, service, router, tests
uv run alembic revision --autogenerate -m "create orders"
uv run alembic upgrade head
uv run python -m pytest
Commands
moarch-py init [name] # interactive scaffold; no name = the current folder (after `uv init`)
moarch-py init --all # default structure, no prompts
moarch-py init --db sqlite # pick the database without the question (postgres | mysql | sqlite)
moarch-py init --dry-run # list every file it would write
moarch-py init --no-install # write the files, skip `uv add`
moarch-py create feature <name> # every layer of a feature, registered at the # moarch: anchors
moarch-py create feature <name> -p path/to/project --dry-run
Coming next, with the same syntax as the Flutter moarch: create model,
create auth --google --apple --github, create worker, create version v2,
create tests, update [name|group], doctor [--fix], release bump, and
init --preset.
What it generates
shop-api/
├── pyproject.toml · uv.lock · .python-version (3.12) · .env.example · .moarch-py.yaml
├── Dockerfile · .dockerignore · docker-compose.yml multi-stage uv build, non-root, healthcheck
├── alembic.ini · migrations/ async env, ruff-formatted revisions
├── .github/workflows/ci.yml ruff, mypy, pytest, migrations on a real DB, image build
├── .pre-commit-config.yaml ruff through uv
├── .vscode/ Ruff as formatter + linter on save
├── AGENTS.md · CLAUDE.md · .agents/skills/ · .claude/ the AI agent guide
├── docs/ARCHITECTURE.md
├── src/shop_api/
│ ├── main.py create_app(): settings, engine, CORS, error handlers, routers
│ ├── core/ config (pydantic-settings), logging, errors (AppError → JSON)
│ ├── db/ Base + naming convention, session, BaseRepository[Model], models registry
│ ├── api/health.py /health and /health/ready
│ ├── api/v1/router.py every feature router, under /api/v1
│ └── features/<name>/ models · schemas · repository · service · router · dependencies
└── tests/ a fresh in-memory database per test; no server needed
Each option in the wizard can be switched off: migrations, Docker, CI, pre-commit, and the AI guide.
The layers: router → service → repository → session. Routers speak HTTP
and return schemas; services hold the rules and commit; repositories are the
only code that queries, and only flush. See the generated
docs/ARCHITECTURE.md.
Ruff everywhere: the same Ruff version (from uv.lock) and rules
([tool.ruff]) format and lint on save in VS Code, in pre-commit and in CI,
and moarch-py formats every file it writes, so a fresh project passes
ruff format --check and ruff check on day one.
Packages are never pinned by moarch: init runs uv add, so every new
project starts on the newest compatible releases, locked in uv.lock.
The AI agent guide
AGENTS.md (read by Codex, Cursor, Copilot, Gemini CLI) states the project's
rules; CLAUDE.md imports it for Claude Code. .agents/skills/ holds
step-by-step skills, with pointers in .claude/skills/:
| Skill | For |
|---|---|
moarch-add-feature |
A new resource through every layer, with its migration and tests |
moarch-write-tests |
API and service tests on the in-memory database |
moarch-fix-bug |
Reproduce with a failing test first, fix in the owning layer |
moarch-review |
Review a diff against the architecture rules |
moarch-make-readable |
Clear names, one job per function, comments that explain why |
moarch-explain |
Teaches the Python, FastAPI, SQLAlchemy and Pydantic behind the code, step by step, with links |
Contributing
See AGENTS.md for the architecture, and .agents/skills/ for the
procedures (add a template, try a real scaffold, release).
uv sync
uv run python -m pytest # every option combination, about a second
uv run python -m pytest -m scaffold # real projects: install, ruff, mypy, pytest
License
MIT
Metadata
Release files for moarch-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| moarch_py-0.1.0.tar.gz | 99.5 kB | With provenance | Details for moarch_py-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moarch_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for moarch_py-0.1.0-py3-none-any.whl |
Total release size: 173.0 kB
Release files / moarch_py-0.1.0.tar.gz
| Download URL | moarch_py-0.1.0.tar.gz |
|---|---|
| Size | 99.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c982fd3fc5bc25ef82bd2aaa013ffa3846569c28febb5c72215bec678389bb85
|
|
BLAKE2b-256 checksum How to use checksums |
00dc2102f91e5a484df90e2087cfe1779b8ef438a4948243cb5679d72079e6ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / moarch_py-0.1.0-py3-none-any.whl
| Download URL | moarch_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 73.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8977d4b94293032ddb5bdc07155769e318fa1548428d022a2bd94a17108ea1eb
|
|
BLAKE2b-256 checksum How to use checksums |
938c398d1826bdc8b11a631c4ef0aa7c3d98798e087ac514e6552e5bb405a765
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logSecurity for moarch-py 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for moarch_py-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.