> ## Documentation Index
> Fetch the complete documentation index at: https://devgraph.ameyalambat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# devgraph build

> Incrementally sync code into the local memory graph

## Usage

```bash theme={null}
devgraph build [paths...] [options]
```

## Arguments

| Argument | Description                          | Default           |
| -------- | ------------------------------------ | ----------------- |
| `paths`  | Files, directories, or globs to scan | current workspace |

If you omit `paths`, DevGraph scans the current workspace root.

## Options

| Option            | Description                                            |
| ----------------- | ------------------------------------------------------ |
| `--out-dir <dir>` | Output directory for generated artifacts               |
| `--force`         | Bypass the shrink guard if a rebuild gets much smaller |
| `--json`          | Print the sync result as JSON                          |
| `--help`          | Show help                                              |

## What Build Does

`devgraph build` is a one-shot sync into local memory:

1. Collect inputs from files, directories, or globs
2. Apply default ignores and `.devgraphignore`
3. Hash candidate files
4. Compare against `.devgraph/manifest.json`
5. Re-extract only changed files
6. Merge per-file cache artifacts into `.devgraph/graph.json`
7. Write the updated manifest and graph back to disk

## Ignore Rules

DevGraph excludes common noise by default, including:

* `.git/`
* `.devgraph/`
* `node_modules/`
* `dist/`
* `build/`
* `.next/`
* `examples/`
* `internal-docs/`
* `apps/docs/`
* static exports and public assets
* lockfiles and generated metadata

You can add a repo-local `.devgraphignore` file with `.gitignore` syntax to exclude more paths.

## Incremental Cache

Build stores per-file extraction state in `.devgraph/cache/`. `manifest.json` records file hashes and extraction version so unchanged files can be reused.

## Examples

Build the current repo:

```bash theme={null}
devgraph build .
```

Build selected paths:

```bash theme={null}
devgraph build apps packages
```

Force a rebuild to overwrite a large shrink:

```bash theme={null}
devgraph build . --force
```

## Output

Build writes the following files to `.devgraph/`:

| File            | Description                                                     |
| --------------- | --------------------------------------------------------------- |
| `manifest.json` | Indexed paths, hashes, kinds, extraction version, and sync time |
| `graph.json`    | Canonical code-memory graph                                     |
| `cache/*.json`  | Per-file extracted artifacts                                    |

## Related Commands

* [`devgraph watch`](/docs/cli/watch) to keep the graph fresh during active work
* [`devgraph query`](/docs/cli/query) for focused retrieval against the graph
* [`devgraph status`](/docs/cli/status) for index health and freshness
