Start from a local repository and the agent you already use. The CLI is the installation and terminal surface for Pathrule. It connects supported agents on macOS, Linux or Windows, and the same workspace knowledge is reachable from the VS Code extension and over MCP. The optional on-device model has separate [platform requirements](/docs/intelligence/local-model).

For a small local project you can explore first, follow [Example workspace](/docs/start/example-workspace). You create and edit it yourself.

## 1. Install a runtime

Install the CLI with Node.js 20.11.1 or newer:

```bash
npm i -g @pathrule/cli
```

- **CLI** runs Pathrule in the terminal, over SSH and in automation. See [CLI install](/docs/cli/install) for detailed requirements.
- **VS Code extension** adds browsing and editing knowledge in the editor, and can connect your AI clients too. See [Pathrule for VS Code](/docs/surfaces/vscode).

You can use both with the same workspace knowledge. Cloud connects them through your account. Local CLI use needs no account.

## 2. Sign in

`pathrule setup` asks you to choose **Cloud** or **Local**. Cloud signs you in for shared workspace knowledge. Local needs no account. Use `pathrule setup --local` to choose Local directly and skip sign-in. [Local or Cloud](/docs/start/local-or-cloud) compares the two. Continue to step 3 to start setup.

For Cloud, you can also sign in separately with a one-time code on a desktop, over SSH or on a headless box:

```bash
pathrule login
```

The CLI prints the code and opens the approval page with it filled in. With no browser on the machine, open the printed URL on any device, enter the code and approve. To use the browser callback flow on this machine instead, run `pathrule login --browser-callback`.

Both flows return you to a signed in state with a session that the runtime keeps refreshed in the background.

## 3. Create a workspace

A workspace is the unit Pathrule scopes content to. It mirrors a repo or a small group of repos on your machine.

With the CLI, everything happens in the folder you run it in, so change into the repository first. The guided route creates or attaches the workspace and connects your AI clients in one run:

```bash
cd ~/repos/my-team
pathrule setup
```

Setup shows your organization, suggests matching workspaces or creates one for this folder, and asks which supported AI clients to connect. It can then offer a first project scan, run by your agent, that proposes memories, rules and skills for you to approve. For a workspace kept on this machine with no account, run `pathrule setup --local`; see [local setup](/docs/cli/install#use-it-without-an-account).

For manual Cloud setup, `pathrule init` creates a workspace named after the folder and attaches the folder to it. Attach an existing Cloud workspace by name or id:

```bash
cd ~/repos/my-team
pathrule workspace attach my-team
```

There is no option that takes a path: the CLI always attaches the current folder. Then connect your clients with `pathrule install <client>` and `pathrule sync`, as [CLI install](/docs/cli/install#connect-your-ai-clients) describes. The runtime resolves your current directory to a workspace using that mapping.

## 4. Write your first memory

The fastest way to confirm that everything is wired up is to write a memory and then open your assistant in the scope it covers. For this guide, put it at the workspace root.

```markdown
Title: Our database is Postgres on Supabase
Body:
- All queries should treat row level security as the source of truth.
- Do not bypass RLS with a service key in user facing code.
- Migrations live in supabase/migrations and run through CI.
```

From the terminal, on a Cloud workspace, the memory is one command. With no `--body`, the CLI opens your editor (`VISUAL` or `EDITOR`) for the body; you can also pass `--body` or pipe the text in.

```bash
pathrule memory add --path / --title "Our database is Postgres on Supabase"
```

Run `pathrule sync` in the repository afterwards so the files and local index your clients read pick up the new memory.

In VS Code, use **New Memory…** in the Pathrule view. On a local workspace, write in the [Local Console](/docs/surfaces/local-console) or ask your agent to save it through Pathrule’s MCP tools. The CLI lists, reads and searches local knowledge but does not add it.

## 5. Watch the hook fire

Open Claude Code or Codex in the directory you attached to the workspace. Start a new turn and ask any question that touches the area the memory covers.

When you submit the prompt, the Pathrule hook reads the cached slice for that path, formats the relevant memories and rules, and hands them to the agent before its first tool call. You will see the memory show up in the context surface your agent exposes, with no extra round trip mid task.

Cursor and GitHub Copilot have no prompt hook: Pathrule reaches them through session and tool hooks, their instruction files and MCP. Windsurf has no hooks and uses its rules file for session bootstrap and MCP for deeper context, so verify those clients with their guides: [Cursor](/docs/mcp/cursor), [GitHub Copilot](/docs/mcp/copilot) and [Windsurf](/docs/mcp/windsurf).

If nothing appears, run the doctor.

```bash
pathrule doctor
```

The doctor checks your sign-in, the workspace and whether this folder is attached to it, each AI client's MCP entry, and the files Pathrule manages in the folder, and names the next command for anything that needs attention. An out-of-date client entry is fixed by `pathrule repair`.

## 6. Add a rule

Memories are facts. Rules are constraints. Add a rule at the same path. On a Cloud workspace, from the terminal:

```bash
pathrule rule add --path / --name "No service key in browser code" --priority high --scope folder \
  --body "Never use the SUPABASE_SERVICE_ROLE_KEY in any file under apps/web. Use the anon key plus row level security."
```

You can also use **New Rule…** in the VS Code extension, or ask your agent to save the rule.

Open Claude Code again. The rule rides in alongside the memory. Priority `high` ranks it near the top. Delivered as context, a rule is a requirement the agent is told to follow, not a block. A rule can also carry an executable constraint: an agent can propose one, it is stored as a proposal and is not enforced, and only once a person has approved it can the pre-tool hook block a matching edit, in clients whose tool hooks honour that decision. See [Rules as guardrails](/docs/hooks/rules-as-guardrails).

## What to read next

- [Core concepts](/docs/start/core-concepts) for the data model behind memories, rules, and skills.
- [How hooks work](/docs/hooks/how-hooks-work) to understand what happens between the cache and the agent.
- [MCP overview](/docs/mcp/overview) for the tool surface your assistant uses to read and write content.
- [CLI command reference](/docs/cli/commands) for every Pathrule CLI command.
