# How to Generate a Wiki from CRG's Knowledge Base: Step-by-Step Guide

> Easily generate a wiki from CRG's knowledge base. Follow this step-by-step guide to export your community structure into Markdown files using the code-review-graph wiki command.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: how-to-guide
- Published: 2026-08-08

---

**Run `code-review-graph wiki` after building your graph to export Code‑Review‑Graph's community structure into Markdown files stored in `.code-review-graph/wiki/`.**

Code‑Review‑Graph (CRG) converts repository analysis into navigable documentation by transforming its internal knowledge graph into Markdown wiki pages. When you generate a wiki from CRG's knowledge base, the tool creates one page per detected community, containing structural relationships and optional AI‑generated summaries. This process leverages the `generate_wiki_tool` MCP tool implemented in the core library.

## Prerequisites for Wiki Generation

### Install Wiki Dependencies

The wiki generation feature requires optional dependencies for LLM‑powered prose generation. Install CRG with the wiki extras group:

```bash
pip install "code-review-graph[wiki]"

```

According to the CRG source code, this installs the necessary packages referenced in the `[wiki]` extra dependency group defined in the project configuration 【/cache/repos/github.com/tirth8205/code-review-graph/main/README.md†L321-L329】.

## Build the Knowledge Graph First

Before generating documentation, you must populate CRG's knowledge base with repository data. The wiki is generated from existing graph data, not source code directly.

Run an initial build or update an existing graph:

```bash

# Full initial build

code-review-graph build

# Or update after making changes

code-review-graph update

```

As documented in the Quick‑Start instructions, these commands analyze your repository structure and populate the graph database 【/cache/repos/github.com/tirth8205/code-review-graph/main/README.md†L57-L64】.

## Generate the Wiki with the CLI

Once your knowledge base contains community data, execute the wiki command:

```bash
code-review-graph wiki

```

This command creates a directory named `.code-review-graph/wiki/` and writes one Markdown file for each detected community (for example, [`authentication.md`](https://github.com/tirth8205/code-review-graph/blob/main/authentication.md) or [`data-processing.md`](https://github.com/tirth8205/code-review-graph/blob/main/data-processing.md)). In [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py), the `wiki` sub‑command wires directly to the `generate_wiki_tool` function 【/cache/repos/github.com/tirth8205/code-review-graph/main/README.md†L363-L364】.

The underlying implementation in [`code_review_graph/wiki.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/wiki.py) handles community slug creation, Markdown formatting, and file I/O operations. Each file contains the community's structural information including member files, relationships, and cross‑references.

## Enhance Wiki Content with LLM Summaries

### Enable LLM Support for Richer Documentation

When you have an LLM service running locally (such as Ollama), CRG automatically generates natural‑language summaries for each community page. Without LLM support, the wiki contains only raw structural data.

Configure your LLM endpoint:

```bash
export OLLAMA_HOST=http://localhost:11434
code-review-graph wiki

```

As noted in the troubleshooting documentation, the wiki generation process checks for available LLM providers to augment the structural data with descriptive prose 【/cache/repos/github.com/tirth8205/code-review-graph/main/docs/TROUBLESHOOTING.md†L176-L179】.

## Access Wiki Data Programmatically

### Query Specific Communities via MCP Tools

For integration with other tools or selective wiki generation, use the MCP tool interface to retrieve specific pages:

```bash

# List available communities

code-review-graph list-communities

# Retrieve Markdown for a specific community

code-review-graph get-wiki-page --name "Authentication"

```

These commands interact with the same `generate_wiki_tool` that powers the batch wiki command, allowing you to extract individual community documentation without generating the full wiki directory.

## Summary

- **Install wiki dependencies** using `pip install "code-review-graph[wiki]"` to enable LLM‑generated summaries.
- **Build the graph** with `code-review-graph build` before attempting wiki generation, as the wiki exports existing knowledge base data.
- **Run the wiki command** (`code-review-graph wiki`) to create Markdown files in `.code-review-graph/wiki/`, with one file per detected community.
- **Enable LLM support** by setting environment variables like `OLLAMA_HOST` to receive natural‑language summaries alongside structural data.
- **Access programmatically** using `list-communities` and `get-wiki-page` commands for targeted documentation retrieval.

## Frequently Asked Questions

### Where does CRG store the generated wiki files?

CRG writes all wiki files to a hidden directory named `.code-review-graph/wiki/` in your project root. Each detected community receives its own Markdown file (for example, [`utils.md`](https://github.com/tirth8205/code-review-graph/blob/main/utils.md) or [`data-processing.md`](https://github.com/tirth8205/code-review-graph/blob/main/data-processing.md)) containing that community's structural graph data and optional LLM summaries.

### Do I need an LLM to generate the wiki?

No. The wiki generation works without LLM dependencies, producing Markdown files with raw structural data including file lists and relationships. However, installing the `[wiki]` extras and configuring an LLM provider (like Ollama) adds natural‑language summaries that make the documentation more readable.

### Can I generate a wiki for a single community instead of the entire repository?

Yes. While the `code-review-graph wiki` command generates pages for all communities, you can use the `get-wiki-page` command with the `--name` parameter to retrieve Markdown for a specific community. First run `code-review-graph list-communities` to see available names, then fetch individual pages as needed.

### What happens if I run the wiki command before building the graph?

The command will likely produce empty or error results because the wiki generation process queries the knowledge base that `build` or `update` populates. Always ensure your graph is current—communities are detected during the build phase in [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py) and stored before the `generate_wiki_tool` can access them.