# Getting started

## Quick Start (One Command)

```bash
cd path/to/your/project
npx devworkspace setup
```

`devworkspace setup` inspects your repository, initializes `.devworkspace/` non-destructively, discovers package verification commands, detects command-contract drift against manifests and directories, verifies feature knowledge, and displays a comprehensive health and readiness report with actionable next steps.

To also install and verify optional integrations (Graphify, Agent Skills, Ponytail), run:

```bash
npx devworkspace setup --integrations --yes
```

---

## Step-by-Step Workflow

### 1. Set up

```bash
cd path/to/your/project
npx devworkspace init
```

`init` finds the project root (the Git top-level if you are in a subfolder, otherwise the current directory; override with `--root`), creates `.devworkspace/`, writes a nested `.gitignore` for machine-local state, and reports which integrations it can see. It never edits your source and is safe to repeat. Use `--dry-run` to preview.

What you get:

```text
.devworkspace/
├── project.json          identity (random id), name, settings, managed-file list
├── .gitignore            ignores local/ and regenerable prompts
├── context/              facts.json, commands.json (testing contract), your architecture.md etc.
├── decisions/            0001-use-redis.md ...
├── tasks/{active,completed}/
├── sessions/             short summaries
├── analysis/             discovery.json (+ onboarding-prompt.md, git-ignored)
├── state/analysis.json   hashes/timestamps used for staleness
└── local/                machine-specific; never committed
```

## 2. Analyze

```bash
npx devworkspace analyze
```

Deterministic only: reads manifests, lockfiles, configs and the file tree (skipping `node_modules`, build output, caches, `.git`, anything in `.gitignore` / `.devworkspaceignore`, and never reading credential files). It writes the discovery report, a **testing contract** (`context/commands.json`), detected facts, and the **onboarding prompt**.

## 3. Onboard with Claude

Open `.devworkspace/analysis/onboarding-prompt.md` and paste it into Claude Code. Claude will:

1. validate the findings against the real code,
2. use Graphify (if available) to understand structure,
3. run `devworkspace agent install` (adds a small managed block to `CLAUDE.md` and installs the `devworkspace` skill, preserving anything you wrote),
4. write concise knowledge into `.devworkspace/context/`,
5. check the testing contract and record a baseline,
6. run the integration manager (`devworkspace setup --integrations`) after asking you once; it installs and verifies Graphify, Agent Skills and Ponytail and reports precise statuses,
7. run `devworkspace doctor` and report unknowns and warnings.

It is told not to modify application source during onboarding.

### Configuring Agent Instructions & Skills Manually

You can also install the agent instructions and skills directly from your terminal:

```bash
# Install Claude operating instructions and .claude/skills/devworkspace/SKILL.md
npx devworkspace agent install --agent claude

# Or configure MCP stdio tools (.mcp.json)
npx devworkspace setup --agent claude-code
```

### Setting Up Graphify & Building the Graph

To enable structural knowledge graphs:

```bash
# Install Graphify CLI and the project skill (.claude/skills/graphify/SKILL.md)
npx devworkspace setup --integrations --yes
```

> [!IMPORTANT]
> **Claude Code Session Reload Requirement:**
> Claude Code indexes skills and slash commands only when a session starts. If Claude Code is already running when `setup --integrations` or `agent install` writes skills:
> - Running `/graphify .` will output: `"/graphify" isn't installed in this session`.
> - **Solution:** In your Claude Code chat prompt, run `/reload-plugins` (or restart the Claude Code session / reload VS Code).
> - Then run `/graphify .` to build the graph (`graphify-out/graph.json`).
> - Once restarted, acknowledge the restart in DevWorkspace:
>   ```bash
>   npx devworkspace integrations status --restarted
>   ```

## 4. Verify

```bash
npx devworkspace doctor
```

- `Core workspace: READY`: Workspace is healthy, instructions are installed and architecture knowledge exists.
- `Integrations` status:
  - `VERIFIED`: CLI executable, project skill, and hooks are confirmed working.
  - `RESTART_REQUIRED`: Skills or plugins were installed; run `/reload-plugins` or restart Claude Code, then acknowledge with `npx devworkspace integrations status --restarted`.
  - `DEGRADED (cli without project skill)`: The Graphify CLI exists, but `.claude/skills/graphify/SKILL.md` is missing. Fix by running `npx devworkspace setup --integrations --yes`.
  - `NOT_INSTALLED`: Optional integration is absent. Missing optional integrations do not fail core checks.

Run `npx devworkspace setup --integrations --dry-run` to see what setup would do, and `--yes` to do it.

## 5. Work normally

Ask Claude for what you want. See [routing](routing.md) for how requests are handled and [claude.md](claude.md) for what was installed. After meaningful work Claude records durable knowledge; you can inspect it any time with `devworkspace context`, and run `devworkspace refresh` after large changes (or after pulling) to catch stale knowledge.

## Feature Map & Graph Navigation

Connect frontend entry points, backend routes, services, database tables, and tests into verifiable feature slices:

```bash
devworkspace feature list
devworkspace feature show auth.login
devworkspace feature validate
devworkspace feature add --id sales.orders --name "Sales Orders" --entry src/pages/Orders.tsx --route src/routes/sales.ts --symbol OrderController
```

Navigate relationships safely with bounded Graphify tracing:

```bash
devworkspace graph status
devworkspace graph trace src/routes/sales.ts --depth 2
```

## Start over

```bash
npx devworkspace reset                 # shows what would be deleted; deletes nothing
npx devworkspace reset --yes           # deletes .devworkspace/ (knowledge, tasks, decisions, local state)
npx devworkspace reset --yes --include-agent-files   # also removes the DevWorkspace block from CLAUDE.md and the managed skill
npx devworkspace init                  # begin again with a new project id
```

Only DevWorkspace's own files are removed: your source code is never touched, text you wrote in `CLAUDE.md` is kept, and a skill you wrote yourself is left alone. Committed knowledge can still be recovered from Git history. Run `devworkspace export` first if you want a copy.

## Install options

```bash
npm install -g devworkspace    # then: devworkspace init
npx devworkspace <command>     # no installation
```

Requires Node.js 20.11+.
