MediaWiki extension · v1.1.4

Batch-edit your wiki with AI — preview every change before you save.

Select pages by title list, category, or template transclusion, run AI operations (wikilinks, spellcheck, formatting, style, templates, or custom instructions), review wiki-style diffs, approve, and save through MediaWiki's normal edit pipeline.

Get started View on GitHub

Features

Built for production wikis: server-side LLM calls, permissions, rate limits, and audit logging.

Batch page selection

Paste titles, load from a category, or find pages that transclude a template (optional prefix filter). Validation shows editable pages and skips problems early.

Six AI operations

Wikilinks, spellcheck, formatting, writing style, templates (with remote reference fetch), and custom instructions.

Server-side batch

The browser starts a batch and polls for progress. Cancel mid-run to stop remaining pages. Configurable concurrency per poll.

Diff & article preview

Lazy-loaded wikitext diffs plus a Preview article button that opens the rendered proposed page in a new tab before save.

Approve before save

Approve per page or in bulk. Saves use your edit summary, draft tokens, and the aibatcheditor change tag.

Review safeguards

Proposal warnings, diff-reviewed confirmations, post-save revision links, rate limits, and Monolog audit channel.

Compatibility

Requires MediaWiki 1.43+ (Vue and Codex in core). Tested on 1.43 LTS through 1.45+.

Environment Supported? Notes
Self-hosted (Docker, VPS, local)YesAdmin installs extension and configures LLM
Private / corporate wikisYesSame requirements
Wiki farms (Miraheze, ShoutWiki)MaybeCustom extensions + outbound HTTPS required
Wikimedia wikis (Wikipedia, Commons)NoThird-party; not in WMF deployment

Processes only existing, non-redirect wikitext pages the user can edit. PHP 8.1+, JavaScript, and outbound HTTPS to the LLM API are required.

AI capabilities and limits

The extension edits wikitext — it is not a web search or research agent.

Can do

  • Edit one page's wikitext per LLM call
  • Follow batch-wide and per-page instructions
  • Clone templates from allowed remote wikis (e.g. es.wikipedia.org)
  • Preview prompts before drafting (optional debug mode)
  • Surgical-edit prompts (v3): operation scope + profile intensity, no invented facts

Cannot do

  • Search the web or call external APIs (weather, news, etc.)
  • Read other pages on your local wiki as context
  • Share context between pages in a batch
  • Edit non-wikitext content or redirects

Prompts follow a surgical-edit contract: smallest necessary change, copy everything else unchanged, return input as-is when already satisfied. Provide external facts in your instructions when needed.

Workflow

  1. Validate pages Title list, category, or template (+ optional prefix). Oversized or non-editable pages are flagged.
  2. Choose operation & profile Pick the AI task and intensity (conservative / balanced / aggressive). Custom hides the profile dropdown and uses balanced intensity. Add batch-wide instructions separate from the wiki edit summary.
  3. Preview prompt Optional: inspect system/user messages before drafting ($wgAIBatchEditorPromptPreview).
  4. Draft Server-side batch with status polling. Unchanged pages show as omitted.
  5. Review diffs Lazy-loaded diffs or Preview article in a new tab; per-page overrides, re-draft, or retry all failed pages at once.
  6. Approve & save Confirmations for unreviewed diffs and risky proposals. Saves require draft tokens.

Safety and review gates

Feature Behavior
Privacy noticeShown when the LLM is configured
Rate-limit noticeDraft disabled when batch exceeds remaining hourly quota
Lazy diffsDiffs load on demand, not automatically
Proposal warningsFlags major deletions, near-empty output, large growth, removed headings
Diff-reviewed gateConfirms approve/save if diffs were not previewed
Draft tokensHMAC tokens bind proposals to user, revision, and content hash
Post-save linksRevision and history links after successful save

Installation

Requires MediaWiki 1.43+ and a Grok-compatible chat completions endpoint (xAI by default).

git clone https://github.com/urimacias/AIBatchEditor/ extensions/AIBatchEditor

Add to LocalSettings.php:

wfLoadExtension( 'AIBatchEditor' );

$wgAIBatchEditorApiUrl = 'https://api.x.ai/v1/chat/completions';
// XAI_API_KEY in $IP/.env — loaded automatically; do not commit the key

Sensible defaults are built in (model grok-4.3, 420 s LLM timeout, batch cap 100, 500 requests/hour, concurrency 1). Set $wgAIBatchEditorConcurrency = 2 for parallel LLM calls; set $wgAIBatchEditorReasoningEffort = 'low' for faster grok-4.5. Batch progress uses CACHE_DB automatically. Store the API key in $IP/.env or Docker .env, never in git.

Users need the aibatchedit right (granted to sysop by default).

Shared hosting / cPanel

Batch progress is stored in CACHE_DB (mw_objectcache) by the extension. Optional APCu for general wiki speed:

$wgMainCacheType = CACHE_ACCEL;
$wgSessionCacheType = CACHE_DB;

Configuration

Setting Default Purpose
$wgAIBatchEditorApiUrl''LLM endpoint (server-side only)
$wgAIBatchEditorApiKey''API key / bearer token
$wgAIBatchEditorModelgrok-4.3Model identifier
$wgAIBatchEditorMaxBatch100Max pages per batch
$wgAIBatchEditorMaxPageSize2097152Max wikitext bytes per page, 2 MiB (0 = no limit)
$wgAIBatchEditorMaxInstructionsLength8192Max AI instruction bytes
$wgAIBatchEditorRequestTimeout420LLM HTTP timeout (seconds)
$wgAIBatchEditorTemperature0.1LLM temperature; lower = stricter instruction following
$wgAIBatchEditorPromptPreviewfalseDebug flag: expose prompts in UI/API (enable only for troubleshooting)
$wgAIBatchEditorRateLimitPerHour500AI requests per user per hour
$wgAIBatchEditorPollIntervalMs2500Client interval between batch status polls
$wgAIBatchEditorConcurrency1Pages per advance (LLM in parallel when > 1)
$wgAIBatchEditorReasoningEffort''xAI effort: low / medium / high (empty = omit)
$wgAIBatchEditorStubModefalseDeterministic AI stub for automated browser tests only
$wgAIBatchEditorTemplateSourceWikihttps://es.wikipedia.orgDefault remote wiki for template references
$wgAIBatchEditorTemplateSourceAllowHostssee extension.jsonAllowed hosts for template source overrides
$wgAIBatchEditorOperationProfilessee extension.jsonPer-operation profile intensity (UI help + LLM prompt)
$wgAIBatchEditorSystemPrompt[]Wiki context after ROLE (WIKI CONTEXT); prefer identity; op checklists need “UNICAMENTE con la operación equivalente”
$wgAIBatchEditorSystemPromptAppend[]Wiki-wide extra system-prompt bullets at end (append-only; operation task takes precedence)

API modules

Module Mode Purpose
aibatcheditorlistreadValidate and list pages; rate-limit status
aibatcheditorpreviewreadBuild LLM prompts without calling the AI
aibatcheditorbatchstartreadStart server-side batch; returns batchId
aibatcheditorbatchadvancereadProcess next batch chunk (LLM work)
aibatcheditorbatchstatusreadRead batch progress (fast; no LLM)
aibatcheditorbatchcancelreadCancel a running batch; clears pending pages
aibatcheditordiffreadRender preview diff
aibatcheditorarticlepreviewreadStage proposed wikitext; return article preview URL
aibatcheditorrefreshdrafttokenswriteRefresh draftToken values before save
aibatcheditorsavewriteSave approved edits (requires draftToken per edit)

The UI uses batchadvance for LLM work and lightweight batchstatus polls for progress. Wikitext and draftToken come from advance responses only. Save recovers stale tokens server-side; aibatcheditorrefreshdrafttokens is available for API integrations.

Development

127 PHPUnit tests (62 unit + 65 integration) + Playwright E2E. Run from the MediaWiki root with dev dependencies installed.

composer install --dev
./extensions/AIBatchEditor/tests/run-phpunit.sh

# E2E (Node.js + sysop credentials + stub mode)
export MW_E2E_USER=Admin
export MW_E2E_PASSWORD='your-password'
export AIBATCHEDITOR_E2E_STUB=1
./extensions/AIBatchEditor/tests/run-e2e.sh

See tests/QA-CHECKLIST.md in the repository for manual release verification.