Skip to main content

Muscles CLI

muscles-cli is the console runtime for Muscles. It uses the same application shape as the HTTP runtimes: an ApplicationMeta class owns a Context, and the context delegates execution to CliStrategy.

Installation

pip install muscles-cli

Canonical ecosystem install matrix is documented in core: Muscles installation matrix.

  • muscles - core contracts, actions, inspect output and canonical documentation.
  • muscles-asgi - ASGI runtime generated projects can target.
  • muscles-wsgi - WSGI runtime generated projects can target.
  • muscles-mcp - MCP projection over the same action contracts.
  • muscles-benchmarks - CLI regression and architecture checks.

Project Scaffolding

Use canonical command muscles new:

muscles new demo --runtime asgi
muscles new demo --runtime wsgi
muscles new demo --runtime cli

Notes:

  • muscular new is not a canonical command.
  • Existing non-empty directory is rejected unless --force is used.

AI Workflow Commands

muscles capabilities --json
muscles inspect --json --app app.application:App
muscles action list --app app.application:App --json
muscles action inspect bookings.echo --app app.application:App --json
muscles action run bookings.echo --app app.application:App --payload-json '{"title":"Call"}' --json
muscles routes --app app.application:App
muscles schemas --app app.application:App
muscles rules --app app.application:App
muscles cli --app app.application:App
muscles generate page Home --with-tests
muscles doctor --json
muscles test --doctor

Quick Start

from muscles import ApplicationMeta, Context, cli
from muscles.cli import CliStrategy


class App(metaclass=ApplicationMeta):
    context = Context(CliStrategy)

    def run(self, *args):
        return self.context.execute(*args, shutup=True)


@cli.group()
def bookings(*args):
    """Booking commands."""
    return True


@bookings.command(command_name="remove")
def remove_booking(*args):
    booking_id = args[0]
    return f"removed {booking_id}"


app = App()
assert app.run("bookings", "remove", "1") == "removed 1"

In a console entry point, call app.run() without arguments. CliStrategy then reads the process arguments from sys.argv[1:]; application code does not need to parse or forward them manually. Passing arguments explicitly is useful for in-process calls and focused examples like the assertion above.

Routing Model

Groups and commands form a tree. That makes CLI routing close to HTTP routing:

  • bookings remove 1 is a nested route with an argument;
  • bookings/list can be normalized by an application before calling the CLI;
  • groups can have handlers, but returning True lets execution continue to a child command.

More detail: docs/routing.md.

Core Stream Output

English: CLI progress output uses core StreamEvent items from StreamResult. render_stream_result() can print human-readable progress/log and result lines, or machine-readable JSON lines. The CLI layer only owns presentation and exit code mapping; stream semantics stay in muscles.core.

Русский: CLI progress output использует core StreamEvent из StreamResult. render_stream_result() может печатать human-readable progress/log/result строки или machine-readable JSON lines. CLI слой отвечает только за presentation и exit code mapping; stream semantics остаётся в muscles.core.

Arguments

Use @cli.argument() for named arguments and @cli.flag() for boolean flags. Required prompted arguments use input() or getpass.getpass() when hidden.

For nested commands, define options on the parent group object:

@cli.group(command_name="bookings")
def bookings(*args):
    return True

@bookings.command(command_name="list")
@bookings.argument("--limit", nargs=1, default="25")
def bookings_list(*args, limit):
    return limit

Canonical invocations for benchmark/automation scripts:

bookings list --limit 10
bookings list --limit=10

Development

Run tests with the core package on PYTHONPATH:

PYTHONPATH=../muscles/src:src python -m pytest -q

Metadata

Release files for muscles-cli 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for muscles-cli 2.0.0
File Size Uploaded Provenance Actions
muscles_cli-2.0.0.tar.gz 23.7 kB With provenance Details for muscles_cli-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for muscles-cli 2.0.0
File Interpreter ABI Platform Actions
muscles_cli-2.0.0-py3-none-any.whl Python 3 none any Details for muscles_cli-2.0.0-py3-none-any.whl

Total release size: 51.0 kB

Release files / muscles_cli-2.0.0.tar.gz

Download URL muscles_cli-2.0.0.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6a5bdade8d8033d16dc624f8567326acd9fa5758438400d1ac60cdbc765e51ff
BLAKE2b-256 checksum
How to use checksums
661d4988603aa7b76a4fcc3637d5c674292852597e943402f8d2322c34e88580
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 4, 2026.

Transparency log

Release files / muscles_cli-2.0.0-py3-none-any.whl

Download URL muscles_cli-2.0.0-py3-none-any.whl
Size 27.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bd1d0f281064854f274a0ce784ad10885761c8a62b3c129e530a9403d7f1bf7
BLAKE2b-256 checksum
How to use checksums
63c9087e8d7d3a7dff19edf1134eeaab9e77afe78d0a1c181911d0aa01733679
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 4, 2026.

Transparency log

Security for muscles-cli 2.0.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for muscles_cli-2.0.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 4, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page