# Initialize a Wiki

Use the /wiki command to generate a comprehensive Wiki with AutoWiki from the Droid CLI.

The `/wiki` command analyzes your repository and generates a structured Wiki covering architecture, modules, APIs, and conventions. Cloud Sync stores the Wiki in the Factory App, and AutoWiki can optionally sync it to GitHub Wiki.

## Quick start

<Steps>
  <Step title="Open a Droid session in your repo">
    Navigate to your project directory and start Droid:
    ```bash
    cd /path/to/your/project
    droid
    ```
  </Step>
  <Step title="Run the wiki command">
    ```
    > /wiki
    ```
    Droid analyzes your codebase and generates markdown files into a local
    `droid-wiki/` folder in your project directory. Once generation is
    complete, Cloud Sync stores the contents in the Factory App.
  </Step>
  <Step title="View the result">
    After Cloud Sync completes, Droid prints a link to your Wiki:
    ```
    Wiki uploaded successfully: https://app.factory.ai/wiki/{wikiRunId}
    ```
    Open the link to browse your documentation, or visit
    <a href="https://app.factory.ai/wiki">app.factory.ai/wiki</a> to see all your Wikis.
  </Step>
</Steps>

## What happens during generation

When you run `/wiki`, Droid performs several steps:

1. **Codebase analysis**: Reads source files, configuration, tests, and documentation to understand the project structure
2. **Page generation**: Produces a set of structured markdown files organized by topic (architecture, modules, APIs, setup, etc.)
3. **Visual screenshots**: If the repository has a [QA skill](/software-factory/automated-qa) installed, Droid launches the application and captures screenshots of web UIs and TUIs to include in the Wiki. Run `/install-qa` to set one up if your repo doesn't have one yet.
4. **Cloud Sync**: Stores the pages and images in the Factory App
5. **GitHub Wiki sync**: For GitHub repos, flattens pages and pushes to GitHub Wiki

<Note>
  Wiki generation uses your current branch and working directory state.
  For the most accurate documentation, run `/wiki` from a clean checkout
  of your default branch.
</Note>

<Tip>
  The first Wiki generation for a repository can take a while because Droid needs
  to analyze the entire codebase from scratch. Subsequent runs are
  significantly faster because they use incremental mode, only updating pages
  affected by code changes since the last generation.
</Tip>

## GitHub Wiki sync

After Cloud Sync stores the Wiki in the Factory App, the Droid CLI automatically syncs it to GitHub Wiki for GitHub-hosted repositories. The sync:

![Generated AutoWiki content synced to GitHub Wiki](/docs-assets/images/wiki/github-wiki-sync.png)

- Flattens the hierarchical page tree into GitHub Wiki's flat format (e.g., `overview/architecture.md` becomes `overview--architecture.md`)
- Rewrites internal links to use the flat filenames
- Generates `_Sidebar.md` with a navigable table of contents
- Generates `Home.md` from your Wiki root page
- Clones `{repo}.wiki.git`, replaces all content, and pushes

### Prerequisites for GitHub sync

- Your repository must be hosted on GitHub
- GitHub Wiki must be initialized. If you've never used it, create the first page at `https://github.com/{owner}/{repo}/wiki`
- Your Git credentials must have push access to the GitHub Wiki repository
- [AutoWiki Cloud Sync](/software-factory/wiki/overview#autowiki-cloud-sync) must not be disabled for your organization

If GitHub Wiki isn't initialized, the Droid CLI prints a message with a link to create the first page and skips the sync without failing.

## Versioning

Each Wiki generation creates a new **Wiki Run** with metadata including:

- Commit hash and branch name
- Whether there were local uncommitted changes
- Droid CLI version used
- Timestamp

You can browse previous versions from the [AutoWiki page in the Factory App](/software-factory/wiki/web-viewer) using the version dropdown.

<RelatedLinks>
  <RelatedLink href='/software-factory/wiki/web-viewer' title='Wiki Browser'>
    Browse the generated Wiki and compare versions in the app.
  </RelatedLink>
  <RelatedLink href='/software-factory/automated-qa' title='Automated QA'>
    Enrich Wikis with screenshots and tests of your application.
  </RelatedLink>
</RelatedLinks>
