Leaf CLI
Command center
Leaf CLI is the fastest way to start an AI-ready Leaf project, run it locally, install first-party modules, scaffold frontend tooling, and share compact context with external assistants.
What it handles
Project shape
Start with lite or MVC without changing ecosystems later.
Modules
Install auth, db, mail, queues, billing, and other Leaf packages quickly.
AI workflow
Start AI-ready, with portable context export when an assistant cannot access the project.
Installation
Make sure Composer is available on your machine:
composer --versionInstall Leaf CLI globally:
composer global require leafs/cli -WVerify the install by running:
leafleaf command becomes available anywhere on your machine.[Error] command not found: leaf
If you get an error saying leaf: command not found, add Composer's global bin directory to your system's PATH. You can find the directory with:
composer global config bin-dir --absoluteCommon locations:
- Windows:
%USERPROFILE%\AppData\Roaming\Composer\vendor\bin - macOS:
$HOME/.composer/vendor/bin - GNU/Linux:
$HOME/.config/composer/vendor/binor$HOME/.composer/vendor/bin
On Bash:
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
source ~/.bashrcOn Zsh:
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.zshrc
source ~/.zshrcCreating apps
Use leaf create to start a new project. You can choose the app shape interactively, or pass a flag when you already know what you want.
leaf create my-app--litePrototypes, scripts, small tools, single-file starts.--mvcFull-stack products, teams, views, controllers, and structure.--apiBackends, mobile apps, headless products, and frontend clients.--consoleCLI tools built with Seedling.You can skip the prompt:
leaf create my-app --lite
leaf create my-app --mvc
leaf create my-app --api
leaf create my-app --consoleRunning your app
Move into your project directory and run the development server:
cd my-app
leaf serveBy default, Leaf serves your app on localhost:5500.
leaf serve --port=8080
leaf serve -p 8080You can also serve a project from another directory:
leaf serve /path/to/your/appUse --port when you need the server on a specific port:
leaf serve --port=8080Automatic dependency installation
When running your app, Leaf will automatically try to install missing dependencies if no vendor directory is found in the project.
Sharing AI context NewPortable project context arrived in Leaf 5Leaf CLI can produce a compact handoff for assistants that cannot enter your project directly.
Agents running inside your project use .leaf/CONTEXT.md as shared project memory. They read it alongside the filesystem and sync useful changes back when they finish, so the next agent starts with the latest map. Leaf MVC and projects created through Leaf CLI need no extra AI configuration.
Use leaf context only when an external assistant cannot access the project:
leaf contextThis scans your project and prints a compact handoff: your actual routes with their handlers and middleware, installed modules, models, schema files, and environment key names (names only, never values), with the shared context appended at the end. Paste that output into the external assistant before asking for larger changes. The output is a portable snapshot, not a replacement for the two-way .leaf/CONTEXT.md used inside the project. The two are opposite halves: the file holds goals and decisions, the command generates the mechanical map.
Prompt with context
AI sees
Scaling a project BetaThe app upgrade workflow is still evolvingThe leaf up command can organize a small Leaf app into MVC structure, but its migration rules and generated output may change while the workflow is tested across more real projects.
Not all apps require a full structure from the start. With Leaf, you can start as small as a single index.php file hosting your application. This is great for prototypes, scripts, and small tools, but as your app grows, you may want to organize it into a more structured MVC format.
We added the leaf up command to help you scale your app without switching frameworks or rewriting everything by hand. It can move assets, organize controller-like code, and prepare MVC conventions around the app you already started.
leaf upThe first time you run leaf up, it will generate a .leaf/migration.yml file that describes the changes it will make to your project. You can edit this file to point to different directories or change the structure before running the migration. Once you're ready, run leaf up again to apply the changes.
Running commands
Use leaf run to execute scripts from your app's composer.json.
leaf run my-commandThis keeps project-specific commands close to the app while still giving you one consistent CLI entry point.
Dependency management
Leaf CLI adds a friendlier layer on top of Composer for Leaf modules and regular Composer packages.
Installing packages
Install a Leaf module:
leaf install authYou can also include the full Composer package name:
leaf install leafs/authInstall multiple packages at once:
leaf install auth db mail
leaf install auth db illuminate/supportInstall a specific version with @:
leaf install auth@4.0 illuminate/support@9.0.2Uninstalling packages
Use uninstall to remove packages:
leaf uninstall auth
leaf uninstall auth db illuminate/supportView commands
Leaf CLI also includes commands for frontend and view tooling.
leaf view:install
leaf view:buildUse view:install to set up a view engine or frontend integration, and view:build to build frontend assets for production.
Command reference
leaf createCreate a new Leaf project.leaf serveRun a local development server.leaf contextPrint compact context for an external assistant.leaf upScale a basic app into MVC structure.leaf installInstall Leaf modules or Composer packages.leaf uninstallRemove modules or packages.leaf runRun a script from composer.json.leaf view:buildBuild frontend assets.