imessage-query

imessage-query is a skill for Claude Code from terrylica/cc-skills. It costs 30 tokens per session (3,257 once invoked), scanned A, original, MIT.

A read-only tool for querying the macOS iMessage SQLite database, the local file that stores Messages conversations. It can decode message text, including some text stored in Apple's binary format.

In plain words
What is it for?
Search conversations, retrieve messages for a contact, extract text, handle tapbacks, and build timestamped timelines.
Why use it?
It makes it possible to search and reconstruct message history when the visible message data is incomplete or difficult to read directly.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; names the TodoWrite tool; mentions Claude Code.

Part of the productivity-tools plugin — 8 skills shipped together , and of cc-skills

Good fit Search conversations, retrieve messages for a contact, extract text, handle tapbacks, and build timestamped timelines.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/terrylica/cc-skills/imessage-query
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add terrylica/cc-skills --skill imessage-query
Clone the repo
git clone --depth 1 https://github.com/terrylica/cc-skills

Made for: Claude Code.

Or install productivity-tools, the plugin that ships this one along with the rest of its 8 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for imessage-query

README.md
[![agentmods](https://agentmods.dev/badge/skills/terrylica/cc-skills/imessage-query/github.svg)](https://agentmods.dev/skills/terrylica/cc-skills/imessage-query)
Your own site
<a href="https://agentmods.dev/skills/terrylica/cc-skills/imessage-query"><img src="https://agentmods.dev/badge/skills/terrylica/cc-skills/imessage-query/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for imessage-query

Your own site · 80×15
<a href="https://agentmods.dev/skills/terrylica/cc-skills/imessage-query"><img src="https://agentmods.dev/badge/skills/terrylica/cc-skills/imessage-query.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,257 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Rogue Agent · line 321
    Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.
    Fix: Prevent the skill from modifying its own code, SKILL.md, or configuration files. Treat skill files as read-only at runtime.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00030 $0.03257
Opus 5 $0.00015 $0.01629
Sonnet 5 $0.00006 $0.00651
Haiku 4.5 $0.00003 $0.00326

Measured 3d ago against content hash 99e3f7967ebb, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

imessage-query scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/decode_attributed_body.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/productivity-tools/skills/imessage-query/SKILL.md · 324 lines

How it starts

The opening of the file, as written. The whole thing — 324 lines — stays where its author put it; the contents beside it link to each section on GitHub.

iMessage Database Query

Query the macOS iMessage SQLite database (~/Library/Messages/chat.db) to retrieve conversation history, decode messages stored in binary format, and build sourced timelines with precise timestamps.

Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

When to Use

  • Retrieving iMessage conversation history for a specific contact
  • Building sourced timelines with timestamps from text messages
  • Searching for keywords across all conversations
  • Debugging messages that appear empty but contain recoverable text
  • Extracting message content that iOS stored in binary attributedBody format

Prerequisites

  1. macOS onlychat.db is a macOS-specific database
  2. Full Disk Access — The terminal running Claude Code must have FDA granted in System Settings > Privacy & Security > Full Disk Access
  3. Read-only — Never write to chat.db. Always use read-only SQLite access.
  4. Optional: pip install pytypedstream — Enables tier 1 decoder (proper typedstream deserialization). Script works without it (falls through to pure-binary tiers 2/3).

Critical Knowledge - The text vs attributedBody Problem

IMPORTANT: Many iMessage messages have a NULL or empty text column but contain valid, recoverable text in the attributedBody column. This is NOT because they are voice messages — iOS stores dictated messages, messages with rich formatting, and some regular messages in attributedBody as an NSAttributedString binary blob.

How to detect

-- Messages with attributedBody but no text (these are NOT necessarily voice messages)
SELECT COUNT(*) as hidden_messages
FROM message m
JOIN chat_message_join cmj ON m.ROWID = cmj.message_id
JOIN chat c ON cmj.chat_id = c.ROWID
WHERE c.chat_identifier = '<CHAT_IDENTIFIER>'
AND (m.text IS NULL OR length(m.text) = 0)
AND m.attributedBody IS NOT NULL
AND length(m.attributedBody) > 100
AND m.associated_message_type = 0
AND m.cache_has_attachments = 0;

Read the full file on GitHub · 324 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 324 lines · 30 tokens per session scan A 99e3f7967ebb

Subscribe to this mod's changes

imessage-query is a skill published in the GitHub repository terrylica/cc-skills (66 stars, last pushed today), licensed MIT. It adds 30 tokens to every session and 3,257 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.

Related

Other skills, from other repositories

database-expert

Advanced database design and administration for PostgreSQL, MongoDB, and Redis. Use when designing schemas, optimizing queries, managing database performance, or implementing data patterns.

travisjneuman/.claude · 36 tokens

generic-fullstack-feature-developer

Guide feature development for full-stack applications with architecture focus. Covers Next.js App Router patterns, NestJS backend services, database models, data workflows, and seamless integration. Use when adding new features, refactoring existing code, or planning major changes.

travisjneuman/.claude · 56 tokens

workstation-offbox-backup

Keep a data-heavy workstation app's local database small and fast while preserving full history off-box, with archived data staying directly readable without a restore step. Splits by data shape — searchable text to a log/search platform, bulk media to snapshotted storage — and pulls data rather than scripting a push.…

dryvist/claude-code-plugins · 100 tokens

dbt-data-transformation

Complete guide for dbt data transformation including models, tests, documentation, incremental builds, macros, packages, and production workflows.

manutej/luxor-claude-marketplace · 30 tokens

redis-state-management

Comprehensive guide for Redis state management including caching strategies, session management, pub/sub patterns, distributed locks, and data structures.

manutej/luxor-claude-marketplace · 28 tokens

postgresql-database-engineering

Comprehensive PostgreSQL database engineering skill covering indexing strategies, query optimization, performance tuning, partitioning, replication, backup and recovery, high availability, and production database management. Master advanced PostgreSQL features including MVCC, VACUUM operations, connection pooling…

manutej/luxor-claude-marketplace · 64 tokens