# ox init (https://sageox.ai/docs/cli/init)

# ox init

Initialize a repository with SageOx, connecting it to the platform and setting up local configuration.

## Usage

<Terminal>
  <TerminalCommand>ox init [flags]</TerminalCommand>
</Terminal>

Run this command from the root of your Git repository after authenticating with `ox login`.

## What Happens During Init

When you run `ox init`, the CLI:

1. **Creates `.sageox/` directory** - Stores local configuration including `config.toml`
2. **Registers with SageOx** - Links your repository to your SageOx account
3. **Scans repository structure** - Analyzes your codebase conventions and patterns
4. **Configures defaults** - Sets up sensible defaults based on detected project type

## Flags

| Flag | Description |
|------|-------------|
| `--name` | Override the repository name |
| `--team` | Associate with a specific team |
| `-y, --yes` | Skip confirmation prompts |
| `--force` | Reinitialize even if already configured |

## The `.sageox/` Directory

```
.sageox/
├── config.toml       # Repository configuration (committed)
└── config.local.toml # Local overrides (gitignored)
```

## Prerequisites

- Git repository with at least one commit
- Authenticated with `ox login`
- Write access to the repository root

## Troubleshooting

**"Not a git repository"** - Run from within an initialized Git repository.

**"Not authenticated"** - Run `ox login` first.

**"Repository already initialized"** - Use `--force` to reinitialize.

## Related Commands

- [ox login](/docs/cli/auth) - Authenticate before initializing
- [ox doctor](/docs/cli/doctor) - Diagnose configuration issues
- [ox prime](/docs/cli/prime) - Activate context for AI agents
