moon init command will initialize moon into a repository and scaffold necessary config files by creating a .moon folder in the destination directory.
How it works
When you runmoon init, the command will:
- Prompt for confirmation - Ask if you want to initialize moon in the target directory (unless
--yesis used) - Detect VCS provider - Automatically detect if you’re using GitHub, GitLab, or Bitbucket based on repository files
- Create configuration directory - Create either
.moonor.config/moondirectory - Generate workspace config - Create a
workspace.ymlfile with sensible defaults including:- Project globs (defaults to
packages/*) - VCS settings (provider and default branch)
- Project globs (defaults to
- Update .gitignore - Append moon cache and docker directories to
.gitignore - Display success message - Show helpful links to documentation and community
Arguments
[dest]- Destination to initialize and scaffold into. Defaults to.(current working directory).
Options
--force- Overwrite existing config files if they exist. If not provided and moon is already initialized, you’ll be prompted to confirm overwrite.--minimal- Generate minimal configurations with sane defaults and skip most prompts.--yes- Skip all prompts and use default values. Useful for automated scripts and CI environments.
Examples
Basic initialization
Initialize moon in the current directory:Initialize in a specific directory
Initialize moon in a subdirectory:Skip prompts
Use the--yes flag for non-interactive initialization:
Force overwrite existing configuration
If moon is already initialized, use--force to overwrite:
Generated files
After runningmoon init, you’ll have the following structure:
workspace.yml will include:
.gitignore will be updated with:
Next steps
After initializing moon:- Configure your projects in
workspace.yml - Add project configurations (
moon.yml) to individual projects - Define tasks for your projects
- Run
moon syncto synchronize the workspace