Agent skill

Sqlite Fts5 Corruption Rebuild

by divinevideo in divinevideo/divine-mobile

Fix SQLite "database disk image is malformed" errors caused by corrupted FTS5 indexes.

MPL-2.0Auto-check passedDatabases

Install Sqlite Fts5 Corruption Rebuild

skills CLI
$ npx skills add divinevideo/divine-mobile --skill sqlite-fts5-corruption-rebuild -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install divinevideo/divine-mobile sqlite-fts5-corruption-rebuild --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/sqlite-fts5-corruption-rebuild .claude/skills/sqlite-fts5-corruption-rebuild && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
sqlite-fts5-corruption-rebuild
GitHub stars
266
Token cost
~992 tokens
SKILL.md length
314 words
Files
1
Skills in repo
103
Repo updated
First seen
Licence
MPL-2.0

At a glance

Fix SQLite "database disk image is malformed" errors caused by corrupted FTS5 indexes.

  • Works in 5 steps: Identify FTS5 tables linked to the… → Stop any processes holding the database… → Rebuild the FTS5 index → …
  • UPDATE/INSERT fails with stepping
  • SKILL.md covers Problem, Context / Trigger Conditions, Solution and Verification, plus 4 more sections
  • Calls sqlite3

What it does

Sqlite Fts5 Corruption Rebuild is an agent skill from divinevideo/divine-mobile. Fix SQLite "database disk image is malformed" errors caused by corrupted FTS5 indexes. Use when: (1) UPDATE/INSERT fails with "stepping, database disk image is malformed" but PRAGMA integritycheck returns "ok", (2) Only specific records fail to update while others succeed, (3) Records contain dirty text with tabs, newlines, or unusual characters that were inserted into FTS5-indexed columns. The misleading error message suggests disk corruption, but the actual issue is FTS5 index corruption from malformed text…

Its SKILL.md is about 990 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases. It works with SQLite. The licence is MPL-2.0.

When your agent uses it

  • UPDATE/INSERT fails with stepping
  • Database disk image is malformed but PRAGMA integritycheck returns ok
  • Only specific records fail to update while others succeed
  • Records contain dirty text with tabs

Example prompts

  • “database disk image is malformed”
  • “stepping, database disk image is malformed”
  • “/sqlite-fts5-corruption-rebuild”

Requirements

  • Node.js

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Identify FTS5 tables linked to the affected table
  2. Stop any processes holding the database open (the rebuild requires exclusive access)
  3. Rebuild the FTS5 index
  4. Retry the failed operation - it should now succeed.
  5. Restart your application server.

What it can do on your machine

Read from SKILL.md and the folder at commit 6487b05. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • sqlite3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • sqlite.org

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Sqlite Fts5 Corruption Rebuild loads about 992 tokens when it runs. Until then it costs about 139 tokens; SKILL.md has 314 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~139
When it runs · the whole SKILL.md, loaded when a task matches
~992

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from divinevideo/divine-mobile at commit 6487b05, republished under its MPL-2.0 licence (© divinevideo). 314 words, ~992 tokens.

Download SKILL.mdSave it as .claude/skills/sqlite-fts5-corruption-rebuild/SKILL.md (or your agent's skills folder).
name
sqlite-fts5-corruption-rebuild
description
Fix SQLite "database disk image is malformed" errors caused by corrupted FTS5 indexes. Use when: (1) UPDATE/INSERT fails with "stepping, database disk image is malformed" but PRAGMA integrity_check returns "ok", (2) Only specific records fail to update while others succeed, (3) Records contain dirty text with tabs, newlines, or unusual characters that were inserted into FTS5-indexed columns. The misleading error message suggests disk corruption, but the actual issue is FTS5 index corruption from malformed text content.
author
Claude Code
version
1.0.0
date
2026-01-23

SQLite FTS5 Index Corruption from Dirty Data

Problem

SQLite returns "database disk image is malformed" (error code 11) when trying to UPDATE or INSERT records, even though PRAGMA integrity_check reports the database as "ok". The error only affects specific records, not all writes.

Context / Trigger Conditions

  • Error message: Error: stepping, database disk image is malformed (11)
  • PRAGMA integrity_check returns ok (misleading!)
  • SELECT queries on the same records work fine
  • Only certain records fail to update; other records in the same table update successfully
  • The affected records contain text with embedded tabs (\t), newlines (\n), or other control characters in columns that are indexed by FTS5
  • A concurrent process (like a Node.js server) may have the database open

Solution

  1. Identify FTS5 tables linked to the affected table:

    sql
    SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%fts%';
  2. Stop any processes holding the database open (the rebuild requires exclusive access):

    bash
    kill $(lsof -ti :PORT)  # Kill the server process
  3. Rebuild the FTS5 index:

    sql
    INSERT INTO table_fts(table_fts) VALUES('rebuild');

    Replace table_fts with your actual FTS5 table name (e.g., people_fts).

  4. Retry the failed operation - it should now succeed.

  5. Restart your application server.

Verification

  • The previously failing UPDATE/INSERT statement now succeeds
  • Full-text search queries still return correct results
  • No more "malformed" errors on subsequent writes

Example

bash
# Error occurs:
sqlite3 data/tracker.db "UPDATE people SET name = 'More' WHERE id = 11;"
# Error: stepping, database disk image is malformed (11)

# But integrity check passes:
sqlite3 data/tracker.db "PRAGMA integrity_check;"
# ok

# And SELECT works fine:
sqlite3 data/tracker.db "SELECT id, name FROM people WHERE id = 11;"
# 11|More Masajes\t\n\t\tEscort 23 años...

# Fix: Stop server, rebuild FTS5 index
kill $(lsof -ti :3001)
sqlite3 data/tracker.db "INSERT INTO people_fts(people_fts) VALUES('rebuild');"

# Now the update works:
sqlite3 data/tracker.db "UPDATE people SET name = 'More' WHERE id = 11;"
# Success!

Prevention

  • Sanitize text before inserting into FTS5-indexed columns:
    javascript
    const cleanName = rawName.replace(/[\t\n\r]+/g, ' ').trim();
  • Strip control characters from scraped data before database insertion
  • Consider using content= (external content) FTS5 tables that can be rebuilt independently without affecting the main table

Notes

  • The error code 11 (SQLITE_CORRUPT) is the same as actual disk corruption, making this hard to diagnose
  • The corruption is in the FTS5 shadow tables (_data, _idx, _docsize), not the main table, which is why integrity_check passes
  • If rebuild fails with "database is locked", ensure no other process has the database open (check with lsof or fuser)
  • This can also happen when records are deleted or updated externally (e.g., via sqlite3 CLI) while a WAL-mode connection is active

References

© divinevideo, MPL-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/sqlite-fts5-corruption-rebuild of divinevideo/divine-mobile.

Open the folder on GitHubat commit 6487b05

Compare with similar skills

Sqlite Fts5 Corruption Rebuild next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Sqlite Fts5 Corruption Rebuild compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Sqlite Fts5 Corruption Rebuild this skilldivinevideo/divine-mobile266—~992Automated safety check: PassMPL-2.0
Iptvnator Sqlite DB Worker4gray/iptvnator7.3k—~824Automated safety check: PassMIT
Analyze Nsys Profilemlc-ai/pith-train355—~1.9kAutomated safety check: PassApache-2.0
Reactive Sqlite UIfastrepl/anarlog9.5k—~699Automated safety check: PassMIT
Composer Forensicsdxos/dxos525—~3.1kAutomated safety check: PassCustom licence
Sqlite Schema Designfastrepl/anarlog9.5k—~1.9kAutomated safety check: PassMIT

Similar skills

  • A skill your agent uses when changing Electron SQLite IPC, database-worker operations, request-scoped progress or cancellation, worker packaging, or runtime verification of non-EPG database work.

    7.3k GitHub stars~824 tokensUpdated yesterday
    DatabasesAuto-check passed
  • Analyze Nsys Profile

    mlc-ai/pith-train

    Query a captured PithTrain Nsight Systems profile to measure compute/communication overlap, locate exposed comm by DualPipeV stage, and inspect per-rank stream behavior.

    355 GitHub stars~1.9k tokensUpdated 5 days ago
    DatabasesAuto-check passed
  • Reactive Sqlite UI

    fastrepl/anarlog

    Build SQLite-backed reactive UI in apps/desktop using stable patterns for reads, selection, forms, writes, and loading states.

    9.5k GitHub stars~699 tokensUpdated today
    DatabasesAuto-check passed
  • Forensically inspect and repair Composer browser profiles — offline (Chrome OPFS / SQLite extract) or live via /recovery.html debug port.

    525 GitHub stars~3.1k tokensUpdated today
    DatabasesAuto-check passed
  • Sqlite Schema Design

    fastrepl/anarlog

    Design or review schemas for crates/cloudsync using SQLite Sync constraints, not generic SQLite advice.

    9.5k GitHub stars~1.9k tokensUpdated today
    DatabasesAuto-check passed
  • Makemigrations

    deusXmachina-dev/memorylane

    Create SQLite migrations for MemoryLane storage schema changes.

    121 GitHub stars~973 tokensUpdated yesterday
    DatabasesAuto-check passed

More from divinevideo/divine-mobile

All 103 skills in this repo
  • Fix ArgoCD ExternalSecret deployment failing with "namespace X is not permitted in project Y".

    266 GitHub stars~931 tokensUpdated today
    Auto-check passed
  • Art Direct

    divinevideo/divine-mobile

    Art direction for any content — reads text, PDF, Word, HTML, PPT, then proposes 2-3 creative directions with photography style, mood, and visual language.

    266 GitHub stars~4.8k tokensUpdated today
    Auto-check passed
  • Async Await Null Race Condition

    divinevideo/divine-mobile

    Fix "Null check operator used on a null value" errors when an object is set to null during an async await.

    266 GitHub stars~881 tokensUpdated today
    Auto-check passed
  • AWS V4 Signing Custom Headers Gcs

    divinevideo/divine-mobile

    Add custom metadata headers (x-amz-meta-) to AWS v4 signed requests for GCS S3-compatible API.

    266 GitHub stars~1k tokensUpdated today
    Auto-check passed
  • Bash Herestring Newline Secrets

    divinevideo/divine-mobile

    Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings.

    266 GitHub stars~791 tokensUpdated today
    Auto-check passed
  • Fix silent video/media processing failures caused by URL extraction code that filters on file extensions (.mp4, .webm, .webp).

    266 GitHub stars~1.1k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Sqlite Fts5 Corruption Rebuild

What does Sqlite Fts5 Corruption Rebuild do?

Fix SQLite "database disk image is malformed" errors caused by corrupted FTS5 indexes. Sqlite Fts5 Corruption Rebuild is an agent skill from divinevideo/divine-mobile. Fix SQLite "database disk image is malformed" errors caused by corrupted FTS5 indexes.

When should I use Sqlite Fts5 Corruption Rebuild?

Sqlite Fts5 Corruption Rebuild fits situations like: UPDATE/INSERT fails with stepping; database disk image is malformed but PRAGMA integritycheck returns ok; only specific records fail to update while others succeed; records contain dirty text with tabs.

How do I install Sqlite Fts5 Corruption Rebuild in Claude Code?

Run `npx skills add divinevideo/divine-mobile --skill sqlite-fts5-corruption-rebuild -a claude-code`. Or copy the skill folder (.agents/skills/sqlite-fts5-corruption-rebuild in divinevideo/divine-mobile) into .claude/skills/sqlite-fts5-corruption-rebuild in your project. Claude Code loads it when a task matches its description.

How do I install Sqlite Fts5 Corruption Rebuild in Codex?

Run `npx skills add divinevideo/divine-mobile --skill sqlite-fts5-corruption-rebuild -a codex`. Or copy the skill folder (.agents/skills/sqlite-fts5-corruption-rebuild in divinevideo/divine-mobile) into .agents/skills/sqlite-fts5-corruption-rebuild in your project. Codex loads it when a task matches its description.

Can I use Sqlite Fts5 Corruption Rebuild in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add divinevideo/divine-mobile --skill sqlite-fts5-corruption-rebuild -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/sqlite-fts5-corruption-rebuild, .gemini/skills/sqlite-fts5-corruption-rebuild, .github/skills/sqlite-fts5-corruption-rebuild and .opencode/skills/sqlite-fts5-corruption-rebuild in your project.

What does Sqlite Fts5 Corruption Rebuild need to run?

Going by SKILL.md and its folder, Sqlite Fts5 Corruption Rebuild needs the command-line tools its instructions call (sqlite3). Our summary lists: Node.js.

Does Sqlite Fts5 Corruption Rebuild access the network?

SKILL.md names 1 domain. As links in the text: sqlite.org. This is read from the text; nothing was executed.

Is Sqlite Fts5 Corruption Rebuild safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Sqlite Fts5 Corruption Rebuild use?

Sqlite Fts5 Corruption Rebuild is published under the MPL-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Sqlite Fts5 Corruption Rebuild use?

About 992 tokens (SKILL.md is roughly 4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Sqlite Fts5 Corruption Rebuild?

Skills that share tags, products or a category with Sqlite Fts5 Corruption Rebuild: Iptvnator Sqlite DB Worker (4gray/iptvnator, 7.3k stars), Analyze Nsys Profile (mlc-ai/pith-train, 355 stars), Reactive Sqlite UI (fastrepl/anarlog, 9.5k stars) and Composer Forensics (dxos/dxos, 525 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Sqlite Fts5 Corruption Rebuild?

divinevideo (a GitHub organization) maintains it in divinevideo/divine-mobile, which has 266 GitHub stars. The repository holds 103 skills in this directory. The repository was last updated on October 9, 2026.

Source: divinevideo/divine-mobile on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.