# CLI (/docs/cli) ## Install the CLI [#install-the-cli] Use Node.js 24 or newer. Install the official package and check the command: ```sh cd ~ npm install --global @okae/cli okae --help ``` If you prefer to skip a global install, run the CLI on demand with npx. Choose your repo with `--repo`: ```sh cd ~ npx @okae/cli init --repo OWNER/NAME ``` An agent can reuse the same npx prefix from your home directory for subsequent commands, with `--repo OWNER/NAME` for repository operations. This keeps your repo’s packages and registry settings out of CLI installation. ## Set up your repo [#set-up-your-repo] With the Okae CLI and Node.js 24 or newer installed, open your repository and run: ```sh okae init ``` The CLI reads your Git remote and reuses your workspace session. On first use, it opens Okae in your browser. Choose **Continue with GitHub** if you're signed out, select the workspace, and authorise access as its GitHub organisation owner. Return to your terminal to see the repository's configured mode and latest assessment. If the repository still needs connecting, follow the browser setup link. You can rerun `okae init` after connecting it. With multiple remotes, use `okae init --repo OWNER/NAME` to select the repository. ## Commands [#commands] | Command | When to use it | | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | `okae init` | Connect your repo or verify its existing setup. | | `okae login` | Authorise a workspace from any directory. The CLI saves the credential in your OS keychain. | | `okae auth status` | See your signed-in account, workspace and session expiry. | | `okae workspace status` | Check available and reserved credits, the number of connected repositories you can access, and whether processing is enabled. Works from any directory. | | `okae repo list` | List repositories you can manage. Use `--limit` and `--offset` to page through results. | | `okae status` | See the repository's setup state, mode and latest assessment link. | | `okae config show` | Read effective settings from the working copy. Use `--live` for the default branch. | | `okae config show --brief` | Summarise the default-branch policy in plain language, for you or your coding agent. | | `okae preflight` | Check your committed changes against the repository's rules before you push. It sends metadata only and uses no credits. | | `okae hook session-start` | Add the policy summary from a Claude Code or Codex hook. See [use Okae with a coding agent](#use-okae-with-a-coding-agent). | | `okae config preview` | Validate your working copy of `okae.yml` and preview its changes. For a managed settings draft, pass `--file changes.json`. | | `okae config apply --file changes.json` | Save managed repository settings from a JSON draft. Changes to `okae.yml` go through Git. | | `okae assessments list` | See recent assessments in your repo. Use `--workspace` to include every repository you can access or `--repo OWNER/NAME` to select one. | | `okae assessments run` | Pick an open PR interactively. Pass a number or GitHub PR URL to submit directly. Use `--no-wait` to return after acceptance. | | `okae assessments show ID` | Inspect an assessment in the authorised workspace, including after you interrupt a waiting terminal. | | `okae logout` | Revoke the session and remove the saved credential. | For a coding agent or script, use `okae status --json`. To open the sign-in link yourself, use `okae login --no-browser`. You can manage repository settings in the [dashboard](/docs/dashboard#manage-repository-policy). Use `okae assessments list --json` or `okae assessments show ID --json` to read the full `reasons` array. The dashboard and CLI text show **Multiple reasons** when a run has more than one. ## Configure a repository [#configure-a-repository] Keep the defaults if they fit. Use managed settings for changes you want to save directly in Okae. Choose `okae.yml` when your team wants policy changes reviewed in Git. After writing or editing a root-level `okae.yml`, run `okae config preview` in your repo to compare its effective settings with the default branch. Run `okae config show` to read the full proposed policy. Both work before staging or committing. Invalid settings produce an error and exit code 1. To use the file in an assessment, commit it on the PR branch. Removing the file previews the inherited settings. Use `okae config show --live` for the live default-branch policy. Selecting a repository explicitly with `--repo` also reads its live policy. When running npx outside your repo, use `config preview --repo OWNER/NAME --file /path/to/your-repo/okae.yml`. To prepare a settings draft, read `storage.repository.revision` from `okae config show --json`. Use that exact value for `expected_revision`. For example, for a repo whose revision is currently `null`: ```json { "expected_revision": null, "updates": { "enable_approvals": false }, "removals": [] } ``` Preview the file, review the effective changes together, then apply it. In a script use `okae config apply --file changes.json --yes` after the owner has agreed. When a field is controlled by `okae.yml`, propose the change in Git. Sessions expire after seven days. If you lose a device or expose a token, open workspace **Settings → Your API sessions → Revoke sessions**. This signs your API clients out of that workspace. ## Assess a pull request [#assess-a-pull-request] ```sh okae assessments run # Pick an open PR in the terminal okae assessments run --json # List candidates for an agent okae assessments run 42 # Submit PR 42 and wait for the result ``` Listing candidates spends no credits. Once you submit a PR, the usual assessment credit rules apply. Ctrl-C stops the local wait. Use `okae assessments show ID` to inspect the accepted run later. ## Use Okae with a coding agent [#use-okae-with-a-coding-agent] Your coding agent can learn the repository's policy and check its work before it opens a PR. That way it can keep routine PRs approvable and tell you when a change will need human review. Install the Okae skill for any agent that supports skills: ```sh npx skills add Okae-AI/skills --skill okae ``` For an agent without skills, add a line to your `AGENTS.md` asking it to run `okae config show --brief` before it starts and `okae preflight` before it pushes. ### Run a preflight before you push [#run-a-preflight-before-you-push] Run `okae preflight` in your repo after you commit: ```sh okae preflight # Compare with the remote default branch okae preflight --base origin/dev # Compare with another branch okae preflight --json # Read rule results in a script or agent ``` The CLI compares your commits with the branch your PR will target, the same way GitHub does. It sends each changed file's path, previous path, status, line counts and Git mode. File contents never leave your machine. A preflight applies your repository's rules: size limits, protected and ignored paths, and the changes that always need human review, such as lockfiles or CI configuration. The policy comes from `okae.yml` on the default branch and your managed settings. A preflight is free. It doesn't create an assessment or use credits, and it's rate-limited per user. A clean result means no rule matched. The assessment still reviews the diff itself, so a clean preflight doesn't promise approval. `okae preflight` and `okae config show --brief` need a signed-in session for the workspace owner. Cloud agents without your session can rely on the PR result. ### Add a hook to Claude Code or Codex [#add-a-hook-to-claude-code-or-codex] A session-start hook gives the agent the policy summary automatically. It never blocks the agent or asks for permission. If Okae is unreachable or you're signed out, it prints nothing and exits 0. For Claude Code, add this to `.claude/settings.json` in your repo or `~/.claude/settings.json`: ```json { "hooks": { "SessionStart": [{ "hooks": [{ "type": "command", "command": "okae hook session-start", "timeout": 30 }] }] } } ``` For Codex, add this to `.codex/hooks.json` in your repo or `~/.codex/hooks.json`, then review and trust the hook with `/hooks`: ```json { "hooks": { "SessionStart": [{ "hooks": [{ "type": "command", "command": "okae hook session-start", "timeout": 30 }] }] } } ``` The hook runs the globally installed `okae` command. Sign in with `okae login` first.