---
url: /en/ai/codewiki.md
description: >
  Explains how to configure the CodeWiki pipeline plugin to automatically
  generate a wiki from a code repository's content, creating a documentation
  center portal on the repository homepage.
---
By configuring the CodeWiki pipeline, you can automatically generate Wiki documentation from your repository's code.
A Wiki portal will appear on the repository homepage, enabling quick documentation center setup.

![CodeWiki Portal](/images/ai/cnb-codewiki-en.png)

## Generating via NPC

The quickest way is to summon the [npc/codewiki](https://cnb.cool/npc/codewiki) NPC to generate or update CodeWiki on
demand, without configuring `.cnb.yml` in your own repository.

1. Star the [npc/codewiki](https://cnb.cool/npc/codewiki) repository.

2. In the repository's Issue or Pull Request comments, summon the NPC with `@npc/codewiki(codewiki)` followed by the
   task, for example:

   ```text
   @npc/codewiki(codewiki) generate codewiki
   @npc/codewiki(codewiki) update codewiki
   ```

The NPC checks the environment, starts the CodeWiki container, tracks the run status, validates the output, and queries
the platform-side knowledge base to confirm the ingestion result.

By default this NPC uses the CNB AI endpoint with knowledge base ingestion enabled (embedding model `bge-m3`).
For configurable parameters and fallback behavior, see the [npc/codewiki](https://cnb.cool/npc/codewiki) repository.

For NPC concepts and summoning rules, see [NPC](../build/npc.md).

## Generating via Pipeline

Use the pipeline plugin when you need Wiki generation to run automatically on events such as tag pushes.

### Step 1: Configure the Pipeline

Plugin image: [cnbcool/codewiki](https://cnb.cool/cnb/plugins/cnbcool/codewiki)

Configure the CodeWiki plugin in the repository's `.cnb.yml`.
It is recommended to use the `tag_push` event to avoid frequent Wiki generation.
For more event types, see [Build Trigger Rules](../build/trigger-rule.md).

```yaml title=".cnb.yml"
$:
  tag_push:
    - docker:
        image: cnbcool/codewiki:latest
      stages:
        - name: generate codewiki
          timeout: 10h
          settings:
            git_doc_dir: /data/codewiki/${CNB_REPO_SLUG}
```

Key parameters:

| Parameter Name | Description | Default Value | Required |
| --- | --- | --- | --- |
| `git_doc_dir` | Directory for generating Wiki documentation | None | Yes |
| `use_codebuddy` | Whether to use the CodeBuddy endpoint; `1` for CodeBuddy, `0` for CNB AI | `1` | No |
| `llm_model_name` | Name of the LLM model to use | `deepseek-v3.1` | No |
| `knowledge_enabled` | Whether to enable knowledge base ingestion | `true` | No |
| `knowledge_embedding_model` | Knowledge base embedding model name | `hunyuan` | No |
| `knowledge_chunk_size` | Text chunk size (token count) | `1500` | No |
| `knowledge_chunk_overlap` | Overlapping token count between adjacent chunks | `0` | No |

> Ingestion is enabled by default: generated Wiki docs are automatically ingested into
> the repository knowledge base. Set `knowledge_enabled` to `false` to opt out.

For more information, see the [cnbcool/codewiki](https://cnb.cool/cnb/plugins/cnbcool/codewiki) plugin documentation.

### Step 2: Access CodeWiki

Click the Wiki portal on the repository homepage to access the CodeWiki page.

## Automatic Knowledge Base Integration

Content generated by CodeWiki is automatically synced to the repository's knowledge base.
Once synced, the repository will be marked as a knowledge base, enabling AI-based Q\&A on CodeWiki content.

For more details on knowledge base configuration and usage, see [Knowledge Base](./knowledge-base.md).
