Get the FREE Ultimate OpenClaw Setup Guide →

gitlab-wiki

npx machina-cli add skill grandcamel/GitLab-Assistant-Skills/gitlab-wiki --openclaw
Files (1)
SKILL.md
8.2 KB

Wiki Skill

Wiki page management for GitLab using glab api raw endpoint calls.

Quick Reference

OperationCommand PatternRisk
List pagesglab api projects/:id/wikis-
Get pageglab api projects/:id/wikis/:slug-
Create pageglab api projects/:id/wikis -X POST -f ...⚠️
Update pageglab api projects/:id/wikis/:slug -X PUT -f ...⚠️
Delete pageglab api projects/:id/wikis/:slug -X DELETE⚠️⚠️
Upload attachmentglab api projects/:id/wikis/attachments -X POST ...⚠️

Risk Legend: - Safe | ⚠️ Caution | ⚠️⚠️ Warning | ⚠️⚠️⚠️ Danger

When to Use This Skill

ALWAYS use when:

  • User mentions "wiki", "wiki page", "documentation page"
  • User wants to create/edit project documentation in GitLab
  • User mentions wiki slugs or wiki content
  • User wants to upload images to wiki

NEVER use when:

  • User wants README files (use gitlab-file)
  • User wants to search wiki content (use gitlab-search with wiki_blobs scope)
  • User wants external documentation (not GitLab wiki)

API Prerequisites

Required Token Scopes: api

Permissions:

  • Read wiki: Reporter+ (for private repos)
  • Write wiki: Developer+ (or based on project settings)

Note: Wiki must be enabled for the project.

Available Commands

List Wiki Pages

# List all wiki pages
glab api projects/123/wikis --method GET

# With pagination
glab api projects/123/wikis --paginate

# Using project path
glab api "projects/$(echo 'mygroup/myproject' | jq -Rr @uri)/wikis"

Get Wiki Page

# Get page by slug
glab api projects/123/wikis/home --method GET

# Get page with spaces in slug (URL-encode)
glab api "projects/123/wikis/$(echo 'Getting Started' | jq -Rr @uri)" --method GET

# Get nested page
glab api "projects/123/wikis/$(echo 'docs/installation' | jq -Rr @uri)" --method GET

# Get page with specific version
glab api "projects/123/wikis/home?version=abc123" --method GET

# Render HTML
glab api "projects/123/wikis/home?render_html=true" --method GET

Create Wiki Page

# Create simple page
glab api projects/123/wikis --method POST \
  -f title="Getting Started" \
  -f content="# Getting Started\n\nWelcome to the project!"

# Create with Markdown format
glab api projects/123/wikis --method POST \
  -f title="Installation Guide" \
  -f content="# Installation\n\n## Prerequisites\n\n- Node.js 18+\n- npm" \
  -f format="markdown"

# Create with custom slug
glab api projects/123/wikis --method POST \
  -f title="API Reference" \
  -f slug="api-docs" \
  -f content="# API Documentation\n\nEndpoints..."

# Create nested page (using directory in slug)
glab api projects/123/wikis --method POST \
  -f title="Database Setup" \
  -f slug="guides/database-setup" \
  -f content="# Database Setup\n\nConfiguration steps..."

Update Wiki Page

# Update content
glab api "projects/123/wikis/$(echo 'Getting Started' | jq -Rr @uri)" --method PUT \
  -f content="# Getting Started\n\n## Updated content\n\nNew information..."

# Update title and content
glab api projects/123/wikis/home --method PUT \
  -f title="Home Page" \
  -f content="# Welcome\n\nUpdated home page content."

# Change format (markdown, rdoc, asciidoc)
glab api projects/123/wikis/readme --method PUT \
  -f format="asciidoc" \
  -f content="= README\n\nAsciidoc content here."

Delete Wiki Page

# Delete page
glab api projects/123/wikis/old-page --method DELETE

# Delete nested page (URL-encode)
glab api "projects/123/wikis/$(echo 'drafts/temp-page' | jq -Rr @uri)" --method DELETE

Upload Attachment

# Upload image
glab api projects/123/wikis/attachments --method POST \
  -F "file=@screenshot.png"

# The response contains the markdown link to use
# {"file_name":"screenshot.png","file_path":"uploads/...","branch":"master","link":{"url":"...","markdown":"![screenshot](uploads/...)"}}

Wiki Page Options

OptionTypeDescription
titlestringPage title (required for create)
slugstringPage URL slug (auto-generated from title if not provided)
contentstringPage content
formatstringContent format: markdown (default), rdoc, asciidoc

Format Support

FormatExtensionDescription
markdown.mdGitHub-flavored Markdown
rdoc.rdocRuby documentation format
asciidoc.asciidocAsciiDoc format
org.orgOrg mode format

Common Workflows

Workflow 1: Create Documentation Structure

project_id=123

# Create home page
glab api projects/$project_id/wikis --method POST \
  -f title="Home" \
  -f content="# Project Wiki\n\n- [Getting Started](Getting-Started)\n- [API Reference](API-Reference)\n- [FAQ](FAQ)"

# Create getting started guide
glab api projects/$project_id/wikis --method POST \
  -f title="Getting Started" \
  -f content="# Getting Started\n\n## Installation\n\n\`\`\`bash\nnpm install\n\`\`\`"

# Create API reference
glab api projects/$project_id/wikis --method POST \
  -f title="API Reference" \
  -f content="# API Reference\n\n## Endpoints\n\n| Method | Path | Description |\n|--------|------|-------------|\n| GET | /users | List users |"

Workflow 2: Backup Wiki Content

# List all pages and save content
mkdir -p wiki_backup
glab api projects/123/wikis --paginate | jq -r '.[].slug' | while read slug; do
  echo "Backing up: $slug"
  glab api "projects/123/wikis/$(echo "$slug" | jq -Rr @uri)" | \
    jq -r '.content' > "wiki_backup/${slug//\//_}.md"
done

Workflow 3: Migrate Wiki Content

# Get page from source project
content=$(glab api projects/123/wikis/home | jq -r '.content')
title=$(glab api projects/123/wikis/home | jq -r '.title')

# Create in target project
glab api projects/456/wikis --method POST \
  -f title="$title" \
  -f content="$content"

Workflow 4: Add Image to Wiki Page

# 1. Upload image
response=$(glab api projects/123/wikis/attachments --method POST -F "file=@diagram.png")

# 2. Get markdown link
markdown_link=$(echo "$response" | jq -r '.link.markdown')

# 3. Update page to include image
current_content=$(glab api projects/123/wikis/architecture | jq -r '.content')
new_content="$current_content

## Diagram

$markdown_link"

glab api projects/123/wikis/architecture --method PUT \
  -f content="$new_content"

Workflow 5: List All Wiki Pages with Titles

glab api projects/123/wikis --paginate | \
  jq -r '.[] | "[\(.title)](\(.slug))"'

Wiki Slugs

Slugs are URL-safe versions of titles:

  • Spaces become hyphens: Getting StartedGetting-Started
  • Special characters are removed
  • Case is preserved

For nested pages, use directory structure in slug:

  • guides/installation creates a page under guides/

Troubleshooting

IssueCauseSolution
404 Not FoundWiki disabled or page doesn't existEnable wiki in project settings, check slug
403 ForbiddenNo write accessNeed Developer+ role or check wiki permissions
Empty contentEncoding issueCheck content string escaping
Slug mismatchAuto-generated slug differsExplicitly set slug parameter
Upload failsWrong content typeUse -F flag for file uploads

Best Practices

  1. Use meaningful slugs: Keep URLs readable and consistent
  2. Create a home page: Start with a home/index page
  3. Use relative links: Link between wiki pages using slugs
  4. Organize with structure: Use slug directories for organization
  5. Include images: Upload screenshots and diagrams for clarity

Related Documentation

Source

git clone https://github.com/grandcamel/GitLab-Assistant-Skills/blob/main/skills/gitlab-wiki/SKILL.mdView on GitHub

Overview

This skill automates GitLab wiki management through API calls using glab. It supports listing pages, reading content, creating/updating/deleting pages, and uploading attachments, enabling programmatic documentation workflows.

How This Skill Works

The skill uses glab api calls to the project’s wikis endpoints (e.g., projects/:id/wikis). It performs standard REST actions: GET to read or list, POST to create, PUT to update, and DELETE to remove, plus POST for attachments. A valid API token with api scope and an enabled wiki are required for success.

When to Use It

  • You need to list all wiki pages for a project.
  • You want to read the content of a wiki page by slug.
  • You want to create, update, or delete a wiki page.
  • You need to upload an attachment to the wiki.
  • You’re working with nested or slug-based wiki pages and need versioned or rendered content.

Quick Start

  1. Step 1: Authenticate with a token that has api scope and ensure the wiki is enabled for the target project
  2. Step 2: List pages to verify access: glab api projects/123/wikis --method GET
  3. Step 3: Create or update a wiki page using glab api projects/123/wikis with -f title and -f content (and optional -f slug)

Best Practices

  • Ensure the GitLab wiki is enabled for the target project before operations.
  • Use an API-scoped token (api scope) with appropriate permissions for the action.
  • URL-encode slugs and paths when constructing endpoints (e.g., spaces become %20).
  • For large wikis, use pagination to avoid missing pages or data.
  • Validate title, slug, and content prior to create/update to prevent conflicts or errors.

Example Use Cases

  • List all wiki pages for project 123: glab api projects/123/wikis --method GET
  • Get the 'home' wiki page: glab api projects/123/wikis/home --method GET
  • Create a new wiki page 'Getting Started' with markdown content
  • Update the 'Home' page content to reflect latest changes
  • Upload an image as an attachment to the wiki

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers