# Osascript Data

> Read macOS app SQLite databases directly. Use when reading iMessage chat history, Chrome browsing history, Safari history, or any local app SQLite DB. Always copy the DB before querying — most apps lock the file while running.

- Skill: `damionrashford/osascript-data` (Agent Skill, multi-file: 6 files)
- Install (CLI): `npx skillmds@latest add damionrashford/osascript-data`
- Raw SKILL.md: https://api.skillmd.com/api/skills/damionrashford/osascript-data/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: damionrashford (https://skillmd.com/u/damionrashford)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/damionrashford/osascript-data

---


# osascript-data

Direct SQLite access to macOS app databases. No API, no auth — plain file reads.
All scripts are pure Python using stdlib only (`sqlite3`, `shutil`).

## The Universal Rule

**Always copy before querying.** Most apps (Chrome, Messages) lock their DB while running.

```python
shutil.copy2(db_path, "/tmp/copy.db")
conn = sqlite3.connect("/tmp/copy.db")
```

## Key Databases

| App             | Path                                                          | Permission needed |
| --------------- | ------------------------------------------------------------- | ----------------- |
| iMessage + SMS  | `~/Library/Messages/chat.db`                                  | Full Disk Access  |
| Chrome History  | `~/Library/Application Support/Google/Chrome/Default/History` | Full Disk Access  |
| Safari History  | `~/Library/Safari/History.db`                                 | Full Disk Access  |
| TCC permissions | `~/Library/Application Support/com.apple.TCC/TCC.db`          | Full Disk Access  |

## Scripts

Run a raw SQL query against any DB (copy-first):

```bash
uv run scripts/sqlite-query.py ~/Library/Messages/chat.db "SELECT * FROM message LIMIT 10"
```

Read recent iMessages with sender, timestamp, and direction:

```bash
uv run scripts/imessage-read.py
uv run scripts/imessage-read.py 50
uv run scripts/imessage-read.py 20 "John"
```

Read Chrome browsing history (Windows epoch → UTC):

```bash
uv run scripts/chrome-history.py
uv run scripts/chrome-history.py 50 github
```

Read Safari browsing history (CoreData epoch → UTC):

```bash
uv run scripts/safari-history.py
uv run scripts/safari-history.py 50 github
```

Audit TCC.db — see all app privacy permission grants:

```bash
uv run scripts/permissions-audit.py
uv run scripts/permissions-audit.py --service kTCCServiceCamera
uv run scripts/permissions-audit.py --allowed
```

## Reference

- [reference/06-sqlite.md](reference/06-sqlite.md) — All app DB paths, Chrome cookie auth, iMessage agent loop pattern
- [reference/09-tcc-permissions.md](reference/09-tcc-permissions.md) — Full TCC service map, what requires Full Disk Access

## iMessage Agent Loop Pattern

```
chat.db (SQLite) → read new message → Python/Claude reasons → osascript → Messages app → sends reply
```

See [reference/06-sqlite.md](reference/06-sqlite.md) for the full pattern with WatchPaths trigger.

