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

> ## Agent Instructions
> The PyPI package is graphifyy, with two y's. The command is graphify.
> /graphify . is typed in an assistant chat, not in a shell.
> Use only commands, flags, and endpoints shown on these pages. Do not invent one.
> Choose the surface before you open a page. Local (Graphify Local) is the graphifyy package on the machine: the skill, the CLI, and the ten-tool MCP. Its pages are the Open Source tab (/open-source/) and the Graphify Local tab on each Integrations page. Graphify is the hosted workspace and https://api.graphify.com/mcp (Streamable HTTP, OAuth, no API key). Its pages are the Graphify tab (/platform/, /concepts/) and the Graphify (hosted) tab on each Integrations page. Prefer Graphify unless the user asks for a local or offline setup. Cookbooks (/cookbooks/) and /mcp/docs-search apply to both. Each page's source frontmatter records this as surface: local, cloud, or both. Buildkite is the CI integration.
> In llms.txt, tell the surface from the page path. Graphify: /platform/ and /concepts/. Local: /open-source/. Most /integrations/ pages cover both, with a Graphify (hosted) tab and a Graphify Local tab. Everything else applies to both.
> graphifyy release notes are published at https://github.com/Graphify-Labs/graphify/releases and https://graphify.com/changelog. The current package version is on PyPI (https://pypi.org/project/graphifyy/).
> The official site is https://graphify.com. These docs are https://docs.graphify.com.
> The local MCP server is the ten tools in the MCP tool reference and reads a graph on the machine. The hosted server is https://api.graphify.com/mcp (Streamable HTTP, OAuth, no API key). The JetBrains, ChatGPT, Codex, and Dots, and Vercel pages use the hosted server, not the ten-tool list. On pages with tabs, the Graphify (hosted) tab uses the hosted server and the Graphify Local tab uses the local skill or the ten-tool server.
> Read https://docs.graphify.com/llms.txt, then open one page's .md link. Use https://docs.graphify.com/llms-full.txt only when one page is not enough.

# Community detection in Graphify Local

> How Graphify Local groups your code into communities with Leiden clustering, names them, and keeps their IDs stable as the graph changes.

A large codebase is easier to navigate in neighbourhoods than file by file. After every build, Graphify Local splits the graph into **communities**: groups of functions, classes, files, and concepts that connect to each other more than to the rest of the code. Communities give `GRAPH_REPORT.md` its structure, colour `graph.html`, and let your agent say "this lives in the parsing layer" instead of listing fifty files.

> [!NOTE]
>
> **Use communities when** you join a new repository and want its real architecture, not the folder layout, or when your agent needs a short map of where a change belongs.

## How it works

**1. Partition**

Graphify runs Leiden community detection on an undirected copy of the graph. If the Leiden package isn't installed, it falls back to Louvain from NetworkX. Install `graphifyy[leiden]` for the better partition.

**2. Down-weight weak edges**

Edges tagged `AMBIGUOUS` count half as much (`GRAPHIFY_AMBIGUOUS_SCALE`, default `0.5`), so a guess can't glue two unrelated groups together. They stay in the graph for `path` and `explain`.

**3. Split oversized groups**

Any community holding more than 25% of the graph (and at least 10 nodes) gets a second Leiden pass on its own subgraph.

**4. Number and score**

Community `0` is the largest. Each one gets a cohesion score: the share of possible internal edges that actually exist.

**5. Name**

With a model configured, Graphify names each community in plain language. Without one, it keeps `Community N` placeholders.

Ordering is canonicalised before clustering, so the same graph gives the same communities on every run, on every machine.

## See it in action

Re-cluster an existing graph without calling a model:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
graphify cluster-only . --no-label --no-viz
```

```text theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
Loading existing graph...
Graph: 3872 nodes, 8833 edges
Re-clustering...
Done - 175 communities. GRAPH_REPORT.md and graph.json updated (--no-viz; graph.html removed).
```

The report lists each one with its cohesion and members:

```markdown GRAPH_REPORT.md theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
## Communities (175 total, 21 thin omitted)

### Community 0 - "Community 0"
Cohesion: 0.03
Nodes (89): _augment_js_reexport_edges(), _NamespaceExportFact, _StarExportFact, ... (+81 more)
```

`graphify explain` shows which community a node belongs to:

```text theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
Node: cluster()
  Source:    corpus/cluster.py L233
  Type:      code
  Community: Community 49
  Degree:    8
```

## Configure

**Name communities**

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
graphify label .
graphify label . --missing-only
```

`--missing-only` keeps names you already have and only fills placeholders. Pick a model with `--backend` and `--model`; by default the backend is detected from your API keys.

**Re-cluster**

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
graphify cluster-only . --no-label
```

Useful after changing `GRAPHIFY_AMBIGUOUS_SCALE`, or after merging graphs.

**Small context models**

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
graphify label . --backend ollama --batch-size 40
```

`--batch-size` (default 100) sets how many communities go in one request. Use 40 for an 8k-context model. `--max-concurrency` defaults to 4 and is forced to 1 for Ollama and `claude-cli`.

## What changes when the code changes

When you run `update`, `watch`, or a git hook, Graphify maps new communities onto the previous IDs by overlap, so "Community 12" stays the same group of code. A saved name is reused only while it still describes the community's members; when a group changes enough, it's renamed on the next `label` run.

## Verify and troubleshoot

| Symptom | Fix |
| - | - |
| One giant community | Install `graphifyy[leiden]`, then run `graphify cluster-only .`. |
| Every community is `Community N` | No model was available. Run `graphify label .` with a backend set. |
| Unrelated code grouped together | Lower `GRAPHIFY_AMBIGUOUS_SCALE` (for example `0`) and re-cluster. |
| Names change on every run | You probably ran `label` without `--missing-only`. |

> **What does cohesion mean?**
>
> It's the ratio of edges inside the community to the most it could have. Code graphs are sparse, so values like 0.02 to 0.1 are normal; compare communities against each other, not against 1.

> **Do communities follow folders?**
>
> No. They follow calls, imports, and references. A community that spans folders often shows a real dependency that the layout hides.

## Run it on a second repository

These examples come from a code-only graph of the open-source [httpx](https://github.com/encode/httpx) repository, built with Graphify Local 0.9.97. Your counts will differ.

```text theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
$ graphify cluster-only . --no-label --no-viz
Loading existing graph...
Graph: 1883 nodes, 3960 edges
Re-clustering...
Done - 106 communities. GRAPH_REPORT.md and graph.json updated (--no-viz; graph.html removed).
```

`graphify label . --missing-only` with no backend configured keeps the placeholders and says why:

```text theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
[graphify label] no LLM backend configured; keeping Community N placeholders. Set an API key (e.g. GOOGLE_API_KEY) or pass --backend.
```

Communities also drive the pull request overlap view. `graphify prs --conflicts` lists pull requests that touch the same community; see [pull request impact](https://docs.graphify.com/open-source/features/pr-impact.md).

## FAQ

**Why did my community names change after `update`?** When the community set changes, Graphify renames communities after their hub node and asks you to run `graphify label`.

## What's next

> **[Deduplication and resolution](https://docs.graphify.com/open-source/features/deduplication.md)**
>
> How edges and nodes are resolved before clustering.

> **[Ask better graph questions](https://docs.graphify.com/open-source/features/querying.md)**
>
> Use communities in your queries.

> **[Try it in Graphify](https://docs.graphify.com/platform/quickstart.md)**
>
> We build and host the graph for you. Start with a 14-day Pro trial, then keep up to 3 repositories on Free. No card required.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.