hanx-mediawiki
Skill1 starsChanged 13 months agoMITView on GitHub
Comprehensive MediaWiki API integration for wiki management and documentation This skill provides complete MediaWiki integration for Claude Code, enabling AI-powered management of wiki content, documentation, and knowledge bases. MediaWiki powers Wikipedia and thousands of enterprise wikis worldwide. Create a .env file in your project root: Low-level API client with full MediaWiki API support. Key Features: - Authentication (login/logout, bot passwords) - Page CRUD operations - Search functionality - Category management - File uploads - Recent changes tracking High-level page management…
- Reads credentials
- Installs packages
In this repository40 other files it gives its agents.
- agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/always.mdcCursor rule
- .cursor/rules/atlassian/atlassian_integration.mdcCursor rule
- .cursor/rules/computer_use/computer_use_agent.mdcCursor rule
- .cursor/rules/documentation.mdcCursor rule
- .cursor/rules/fstrent_spec_tasks/claude_code_cli.mdcCursor rule
- .cursor/rules/github/github_integration.mdcCursor rule
- .cursor/rules/powershell.mdcCursor rule
- .cursor/rules/silicon_valley_personality.mdcCursor rule
- .cursor/rules/virtual_environments_python.mdCursor rule
- .cursor/rules/web_tools/web_tools.mdcCursor rule
- artifacts-builderSkill
- atlassian-integrationSkill
- claude-code-cli-integrationSkill
- computer-use-agentSkill
- deep-researchSkill
- fstrent-code-reviewerSkill
- fstrent-planningSkill
- fstrent-qaSkill
- fstrent-task-managementSkill
- github-integrationSkill
- hanx-database-toolsSkill
- hanx-knowledge-baseSkill
- hanx-youtube-researcherSkill
- internal-commsSkill
- mcp-builderSkill
- oracle-apex-developmentSkill
- patent-filing-aiSkill
- Project SetupSkill
- research-methodologySkill
- skill-creatorSkill
- startup-business-formationSkill
- startup-product-developmentSkill
- startup-resource-accessSkill
- startup-vc-fundraisingSkill
- template-skillSkill
- web-toolsSkill
- youtube-rag-storageSkill
- youtube-video-analysisSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 6 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 20
Create a .env file in your project root:
- Distinctive: line 384
All managers support Python context managers:
- Distinctive: line 458
Create a new bot password with appropriate permissions
- Very specific: line 459
Use bot username and password in your .env file
- Very specific: line 517
Never commit credentials: Use .env files and add them to .gitignore
- Distinctive: line 518
Use bot passwords: Create dedicated bot accounts with minimal permissions
- Distinctive: line 520
HTTPS only: Always use HTTPS URLs for API endpoints
- Distinctive: line 542
Ensure your bot account has the necessary permissions:
- Distinctive: line 662
Check MediaWiki API documentation: https://www.mediawiki.org/wiki/API:Main_page
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MediaWiki Integration Skill
Comprehensive MediaWiki API integration for wiki management and documentation
Overview
This skill provides complete MediaWiki integration for Claude Code, enabling AI-powered management of wiki content, documentation, and knowledge bases. MediaWiki powers Wikipedia and thousands of enterprise wikis worldwide.
Quick Start
Prerequisites
# Install required Python packages
pip install requests python-dotenvEnvironment Setup
Create a .env file in your project root:
MEDIAWIKI_API_URL=https://your-wiki.com/api.php
MEDIAWIKI_USERNAME=your_username
MEDIAWIKI_PASSWORD=your_password_or_bot_tokenBasic Usage
from scripts.mediawiki_api import get_mediawiki_client
# Create authenticated client
wiki = get_mediawiki_client(auto_login=True)
# Create a page
wiki.create_page(
title="My New Page",
content="This is the page content in **wikitext** format.",
summary="Created via API"
)
# Search wiki
results = wiki.search("python programming", limit=10)
# Get page content
page = wiki.get_page("Main Page")
print(page['content'])Core Modules
1. MediaWiki API Client (mediawiki_api.py)
Low-level API client with full MediaWiki API support.
Key Features:
- Authentication (login/logout, bot passwords)
- Page CRUD operations
- Search functionality
- Category management
- File uploads
- Recent changes tracking
Example:
from scripts.mediawiki_api import MediaWikiAPI
# Initialize client
client = MediaWikiAPI(
api_url="https://wiki.example.com/api.php",
username="bot_user",
password="bot_password"
)
# Login
client.login()
# Create/edit page
result = client.edit_page(
title="Tutorial:Python",
content="# Python Tutorial\n\nLearn Python basics...",
summary="Initial tutorial creation"
)
# Search
results = client.search("machine learning", limit=20)
for result in results:
print(f"{result['title']}: {result['snippet']}")
# Logout
client.logout()2. Page Manager (page_manager.py)
High-level page management utilities.
Key Features:
- Bulk page operations
- Page history and revisions
- Move/rename pages
- Page protection
- Content appending/prepending
- Backlink tracking
Example:
from scripts.page_manager import PageManager
manager = PageManager()
# Create or update multiple pages
pages = [
{
'title': 'Project:Overview',
'content': '# Project Overview\n\nThis project...',
'summary': 'Initial overview'
},
{
'title': 'Project:Setup',
'content': '# Setup Guide\n\nFollow these steps...',
'summary': 'Setup instructions'
}
]
results = manager.bulk_create_pages(pages)
# Append to existing page
manager.append_to_page(
title="Project:Changelog",
text="\n## Version 2.0\n- New features...",
summary="Added v2.0 changelog"
)
# Get page history
history = manager.get_page_history("Main Page", limit=10)
for revision in history:
print(f"{revision['timestamp']}: {revision['comment']}")3. Search Manager (search_manager.py)
Advanced search capabilities.
Key Features:
- Full-text search with ranking
- Title search and prefix matching
- Category-based filtering
- Regex search support
- Similar page discovery
- Search statistics
Example:
from scripts.search_manager import SearchManager
search = SearchManager()
# Advanced search with filters
results = search.advanced_search(
query="API documentation",
filters={
'namespace': 0, # Main namespace
'min_size': 1000, # At least 1KB
'category': 'Documentation'
},
limit=10
)
# Find similar pages
similar = search.find_similar_pages("Python Tutorial", limit=5)
for page in similar:
print(f"{page['title']}: similarity={page['similarity_score']}")
# Search with prefix
prefixed_pages = search.search_prefix("User:", limit=50)4. Category Manager (category_manager.py)
Category organization and management.
Key Features:
- Category tree navigation
- Bulk categorization
- Category merging
- Category analysis
- Automatic category suggestions
- Uncategorized page detection
Example:
from scripts.category_manager import CategoryManager
cat_manager = CategoryManager()
# Create category
cat_manager.create_category(
category_name="API Documentation",
description="Documentation for our APIs",
parent_categories=["Documentation", "Technical"]
)
# Bulk categorize pages
cat_manager.bulk_categorize(
pages=["API:Auth", "API:Users", "API:Data"],
categories=["API Documentation", "Developer Resources"]
)
# Analyze category
analysis = cat_manager.analyze_category("Documentation")
print(f"Total pages: {analysis['pages']}")
print(f"Subcategories: {analysis['subcategories']}")
# Suggest categories for a page
suggestions = cat_manager.suggest_categories("New API Page")
for suggestion in suggestions:
print(f"{suggestion['category']}: confidence={suggestion['confidence']}")5. File Uploader (file_uploader.py)
File upload and media management.
Key Features:
- Single and bulk uploads
- Directory uploads
- Duplicate detection
- File metadata management
- Usage tracking
- File re-uploads
Example:
from scripts.file_uploader import FileUploader
uploader = FileUploader()
# Upload single file
result = uploader.upload_file(
filepath="docs/architecture.png",
wiki_filename="Architecture_Diagram.png",
description="System architecture overview",
categories=["Diagrams", "Architecture"]
)
# Bulk upload from directory
results = uploader.upload_directory(
directory="docs/images/",
pattern="*.png",
description_template="Documentation image: {filename}",
categories=["Documentation", "Images"]
)
# Get file usage
usage = uploader.get_file_usage("Logo.png")
print(f"Logo used in {len(usage)} pages")
# Re-upload new version
uploader.reupload_file(
filepath="docs/logo_v2.png",
wiki_filename="Logo.png",
comment="Updated logo design"
)Use Cases
1. Documentation Project Management
# Automated documentation updates
from scripts.page_manager import PageManager
from scripts.category_manager import CategoryManager
manager = PageManager()
cat_manager = CategoryManager()
# Create documentation structure
docs = [
{'title': 'Docs:Getting Started', 'content': '...'},
{'title': 'Docs:API Reference', 'content': '...'},
{'title': 'Docs:Examples', 'content': '...'}
]
results = manager.bulk_create_pages(docs)
# Categorize all docs
doc_pages = [d['title'] for d in docs]
cat_manager.bulk_categorize(
pages=doc_pages,
categories=["Documentation", "User Guide"]
)2. Knowledge Base Maintenance
# Find and fix uncategorized pages
from scripts.category_manager import CategoryManager
cat_manager = CategoryManager()
# Find uncategorized pages
uncategorized = cat_manager.find_uncategorized_pages(limit=100)
# Auto-suggest and apply categories
for page_title in uncategorized:
suggestions = cat_manager.suggest_categories(page_title, max_suggestions=3)
if suggestions:
# Apply top suggestion
top_category = suggestions[0]['category']
cat_manager.client.add_category(page_title, top_category)
print(f"Added {page_title} to {top_category}")3. Content Migration
# Migrate content from external source
from scripts.page_manager import PageManager
import json
manager = PageManager()
# Load external content
with open('migration_data.json', 'r') as f:
data = json.load(f)
# Migrate pages
for item in data:
manager.create_or_update_page(
title=item['title'],
content=item['content'],
summary=f"Migrated from {item['source']}"
)4. Team Wiki Automation
# Weekly status report automation
from scripts.page_manager import PageManager
from datetime import datetime
manager = PageManager()
# Generate weekly report
week = datetime.now().strftime("%Y-W%W")
report_title = f"Status Reports/{week}"
report_content = f"""
# Weekly Status Report - {week}
## Completed Tasks
* Task 1
* Task 2
## In Progress
* Task 3
## Blockers
* None
"""
manager.create_page(
title=report_title,
content=report_content,
summary=f"Weekly status report for {week}"
)
# Add to archive category
from scripts.category_manager import CategoryManager
cat_manager = CategoryManager()
cat_manager.client.add_category(report_title, "Status Reports")Advanced Features
Context Manager Support
All managers support Python context managers:
from scripts.mediawiki_api import get_mediawiki_client
from scripts.page_manager import PageManager
# Automatic login/logout
with get_mediawiki_client() as wiki:
page = wiki.get_page("Main Page")
print(page['content'])
# Automatic resource cleanup
with PageManager() as manager:
manager.create_or_update_page(
title="Test Page",
content="Test content"
)Error Handling
from scripts.mediawiki_api import MediaWikiAPI, MediaWikiAPIError
try:
wiki = MediaWikiAPI(api_url="https://wiki.example.com/api.php")
wiki.login("username", "password")
result = wiki.create_page(
title="Test",
content="Content",
summary="Test"
)
except MediaWikiAPIError as e:
print(f"MediaWiki error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")Batch Processing
from scripts.page_manager import PageManager
manager = PageManager()
# Process pages in batches
def update_template(page_title):
page = manager.client.get_page(page_title)
if page:
# Add template to page
new_content = "{{Infobox}}\n" + page.get('content', '')
manager.client.edit_page(
title=page_title,
content=new_content,
summary="Added infobox template"
)
# Get all pages in category
from scripts.category_manager import CategoryManager
cat_manager = CategoryManager()
pages = cat_manager.client.get_pages_in_category("Articles", limit=500)
for page in pages:
update_template(page['title'])Best Practices
1. Use Bot Passwords
For automated operations, always use bot passwords instead of account passwords:
- Go to Special:BotPasswords on your wiki
- Create a new bot password with appropriate permissions
- Use bot username and password in your
.envfile
2. Respect Rate Limits
import time
# Add delays between bulk operations
for page in pages:
manager.update_page(page)
time.sleep(0.5) # 500ms delay3. Use Descriptive Edit Summaries
# Good
wiki.edit_page(
title="API Docs",
content=new_content,
summary="Updated API endpoints for v2.0 release"
)
# Bad
wiki.edit_page(
title="API Docs",
content=new_content,
summary="update"
)4. Handle Errors Gracefully
from scripts.page_manager import PageManager
manager = PageManager()
pages = ["Page1", "Page2", "Page3"]
results = []
for page_title in pages:
try:
result = manager.update_page(page_title, content)
results.append({'page': page_title, 'success': True})
except Exception as e:
results.append({'page': page_title, 'success': False, 'error': str(e)})
# Log results
for r in results:
if r['success']:
print(f"✓ {r['page']}")
else:
print(f"✗ {r['page']}: {r['error']}")Security Considerations
- Never commit credentials: Use
.envfiles and add them to.gitignore - Use bot passwords: Create dedicated bot accounts with minimal permissions
- Validate inputs: Sanitize user inputs before creating pages
- HTTPS only: Always use HTTPS URLs for API endpoints
- Token management: Tokens are automatically managed and refreshed
Troubleshooting
Authentication Issues
# Test connection
from scripts.mediawiki_api import MediaWikiAPI
client = MediaWikiAPI(api_url="https://wiki.example.com/api.php")
try:
client.login("username", "password")
print("✓ Login successful")
except Exception as e:
print(f"✗ Login failed: {e}")Permission Errors
Ensure your bot account has the necessary permissions:
edit- Edit pagesmove- Move pagesdelete- Delete pagesupload- Upload filesprotect- Protect pages
API URL Format
Correct API URL format:
https://your-wiki.com/api.php
https://your-wiki.com/w/api.php
https://en.wikipedia.org/w/api.phpIntegration with Claude Code
This skill is designed for seamless integration with Claude Code workflows:
# Example: Claude Code usage
# User: "Update all pages in the API Documentation category with the new template"
from scripts.category_manager import CategoryManager
from scripts.page_manager import PageManager
cat_manager = CategoryManager()
page_manager = PageManager()
# Get pages in category
pages = cat_manager.client.get_pages_in_category("API Documentation")
# Update each page
for page in pages:
current = page_manager.client.get_page(page['title'])
if current:
new_content = "{{API Template}}\n" + current.get('content', '')
page_manager.client.edit_page(
title=page['title'],
content=new_content,
summary="Added API template via Claude Code"
)
print(f"Updated {len(pages)} pages")API Reference
MediaWikiAPI
login(username, password)- Authenticate with MediaWikilogout()- End sessionget_page(title, get_content=True)- Retrieve pagecreate_page(title, content, summary)- Create pageedit_page(title, content, summary, ...)- Edit pagedelete_page(title, reason)- Delete pagesearch(query, limit, namespace)- Search contentget_categories(title)- Get page categoriesadd_category(title, category, summary)- Add categoryget_pages_in_category(category, limit)- List category membersupload_file(filename, filepath, description, ...)- Upload fileget_recent_changes(limit, namespace, show_bot)- Get recent changes
PageManager
create_or_update_page(title, content, summary, force_create)- Create/update pagebulk_create_pages(pages, default_summary)- Bulk createmove_page(from_title, to_title, reason, ...)- Move/renameprotect_page(title, protections, expiry, reason)- Protect pageappend_to_page(title, text, summary, section)- Append contentprepend_to_page(title, text, summary)- Prepend contentget_page_history(title, limit)- Get revision historyget_page_links(title, namespace, limit)- Get outgoing linksget_backlinks(title, limit)- Get incoming links
SearchManager
search_full_text(query, limit, namespace, sort_by)- Full-text searchsearch_titles(query, limit, namespace)- Title searchsearch_prefix(prefix, limit, namespace)- Prefix searchsearch_by_category(category, search_query, limit)- Category searchadvanced_search(query, filters, limit)- Advanced searchfind_similar_pages(title, limit)- Find similar pagessearch_statistics(query)- Get search stats
CategoryManager
create_category(category_name, description, parent_categories)- Create categoryget_category_tree(category, depth, include_pages)- Get treeget_parent_categories(category, recursive)- Get parentsbulk_categorize(pages, categories, summary)- Bulk categorizeremove_category(page_title, category, summary)- Remove categoryfind_uncategorized_pages(namespace, limit)- Find uncategorizedsuggest_categories(page_title, max_suggestions)- Suggest categoriesanalyze_category(category)- Analyze categorymerge_categories(source, target, delete_source)- Merge categories
FileUploader
upload_file(filepath, wiki_filename, description, ...)- Upload filebulk_upload(files, default_description, default_categories)- Bulk uploadupload_directory(directory, pattern, ...)- Upload directoryget_file_info(filename)- Get file infoget_file_usage(filename, limit)- Get file usagedelete_file(filename, reason)- Delete filereupload_file(filepath, wiki_filename, comment)- Re-upload file
Version
Current Version: 1.0.0
License
Part of the AI Project Template - MediaWiki Integration Skill
Support
For issues, questions, or contributions:
- File issues in the project repository
- Check MediaWiki API documentation: https://www.mediawiki.org/wiki/API:Main_page
- Review skill examples in the
examples/directory
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

