Atuin History Cleanup
Overview
Audit first, delete second. Use the bundled script to summarize duplicate pressure and high-confidence typo-like retries. For typo cleanup, prefer the transactional cleanup-typos command so the flow snapshots history.db, uploads the current host history store, deletes candidates, verifies the result, and rolls back automatically if verification fails.
Read references/atuin-cli.md when you need the exact delete, dedup, or prune behavior.
Use When
- Reviewing a noisy Atuin
history.db before removing anything.
- Estimating how much
atuin history dedup would remove while still keeping the newest repeated entries.
- Looking for typo-like retries such as
gti status followed by git status.
- Running a transactional typo cleanup with backup, verification, and rollback.
- Rechecking an Atuin cleanup plan without mutating the database directly.
Guardrails
- Always run
atuin info and the audit script before any destructive step.
- Treat duplicate cleanup as global.
atuin history dedup is not a single-command delete tool.
atuin search --delete is query-wide and follows Atuin's active search semantics. Do not use it manually for typo cleanup.
cleanup-typos is the only approved automation path for typo deletion. It may use atuin search --delete only after a strict uniqueness gate; any ambiguous match must fall back to the interactive inspector path.
cleanup-typos must snapshot history.db before deletion and delay the final remote sync until verification passes.
- Rollback is whole-database restore, not selective row restore.
- Re-confirm every destructive command immediately before running it.
- Do not delete rows directly from SQLite.
- Do not edit Atuin config as part of this skill.
history_filter and cwd_filter tuning is out of scope for v1.
Workflow
- Resolve the active database:
atuin info
- Run the audit:
uv run python skills/atuin-history-cleanup/scripts/atuin_history_cleanup.py audit
Useful flags:
uv run python skills/atuin-history-cleanup/scripts/atuin_history_cleanup.py audit --db-path ~/.local/share/atuin/history.db --dupkeep 3 --before now --typo-window-seconds 300 --max-typos 20
Review the duplicates section first.
Use the reported atuin history dedup --dry-run ... command. If the dry run matches expectations, rerun the same command without --dry-run.
Review the typos section second and choose one path:
Preferred transactional path:
uv run python skills/atuin-history-cleanup/scripts/atuin_history_cleanup.py cleanup-typos
Useful flags:
uv run python skills/atuin-history-cleanup/scripts/atuin_history_cleanup.py cleanup-typos --db-path ~/.local/share/atuin/history.db --before now --typo-window-seconds 300 --max-typos 20 --backup-dir ~/.local/share/atuin/cleanup-backups/manual-run
Manual review path:
Start with the suggested atuin search -i --search-mode prefix ... preview command. The audit will also add --cwd <cwd> when it knows the original working directory, so review stays narrow even if your default Atuin config uses skim or another fuzzy mode. In the TUI inspector, use Ctrl+O, confirm the exact entry, then Ctrl+D to delete that one row.
- Stop after the cleanup you actually verified. Do not keep expanding the scope.
What The Audit Does
- Resolves the database path from
atuin info unless --db-path is provided.
- Opens the SQLite database in read-only mode and inspects only
id, timestamp, exit, command, cwd, session, and hostname.
- Groups duplicates by
(command, cwd, hostname) and reports how many rows exceed --dupkeep.
- Emits typo review commands with an explicit
--search-mode prefix override and never emits atuin search --delete.
cleanup-typos first runs the same typo audit, then creates a snapshot, writes pre_audit.json, plan.json, and post_verify.json, and only commits the deletion to remote sync after verification succeeds.
- Detects typo candidates only when all of these are true:
- same session
- within the configured window
- arguments after the first token are identical
- previous command exited non-zero
- the first token looks rare
- the corrected token is much more common
- the token change is a single-edit or adjacent-transposition typo
- Excludes path- or script-like first tokens from typo suggestions.
Output Expectations
duplicates gives one global preview/apply pair for history dedup.
typos gives per-row review data: id, time, cwd, original command, suggested correction, reason, and shell-safe preview commands for inspector review only.
--format json is preferable when another tool needs to post-process the audit.
cleanup-typos prints a text summary and leaves its backup and verification artifacts in the chosen backup directory.
1---
2name: atuin-history-cleanup
3description: Use when auditing Atuin shell history for noisy duplicates or high-confidence typo/retry pairs and when preparing safe preview-first cleanup steps without editing the SQLite database directly.
4metadata:
5 source: https://skillmd.com/skills/aibot88/atuin-history-cleanup
6---
7
8# Atuin History Cleanup
9
10## Overview
11
12Audit first, delete second. Use the bundled script to summarize duplicate pressure and high-confidence typo-like retries. For typo cleanup, prefer the transactional `cleanup-typos` command so the flow snapshots `history.db`, uploads the current host history store, deletes candidates, verifies the result, and rolls back automatically if verification fails.
13
14Read `references/atuin-cli.md` when you need the exact delete, dedup, or prune behavior.
15
16## Use When
17
18- Reviewing a noisy Atuin `history.db` before removing anything.
19- Estimating how much `atuin history dedup` would remove while still keeping the newest repeated entries.
20- Looking for typo-like retries such as `gti status` followed by `git status`.
21- Running a transactional typo cleanup with backup, verification, and rollback.
22- Rechecking an Atuin cleanup plan without mutating the database directly.
23
24## Guardrails
25
26- Always run `atuin info` and the audit script before any destructive step.
27- Treat duplicate cleanup as global. `atuin history dedup` is not a single-command delete tool.
28- `atuin search --delete` is query-wide and follows Atuin's active search semantics. Do not use it manually for typo cleanup.
29- `cleanup-typos` is the only approved automation path for typo deletion. It may use `atuin search --delete` only after a strict uniqueness gate; any ambiguous match must fall back to the interactive inspector path.
30- `cleanup-typos` must snapshot `history.db` before deletion and delay the final remote sync until verification passes.
31- Rollback is whole-database restore, not selective row restore.
32- Re-confirm every destructive command immediately before running it.
33- Do not delete rows directly from SQLite.
34- Do not edit Atuin config as part of this skill. `history_filter` and `cwd_filter` tuning is out of scope for v1.
35
36## Workflow
37
381. Resolve the active database:
39
40```bash
41atuin info
42```
43
442. Run the audit:
45
46```bash
47uv run python skills/atuin-history-cleanup/scripts/atuin_history_cleanup.py audit
48```
49
50Useful flags:
51
52```bash
53uv run python skills/atuin-history-cleanup/scripts/atuin_history_cleanup.py audit --db-path ~/.local/share/atuin/history.db --dupkeep 3 --before now --typo-window-seconds 300 --max-typos 20
54```
55
563. Review the `duplicates` section first.
57 Use the reported `atuin history dedup --dry-run ...` command. If the dry run matches expectations, rerun the same command without `--dry-run`.
58
594. Review the `typos` section second and choose one path:
60 Preferred transactional path:
61
62```bash
63uv run python skills/atuin-history-cleanup/scripts/atuin_history_cleanup.py cleanup-typos
64```
65
66 Useful flags:
67
68```bash
69uv run python skills/atuin-history-cleanup/scripts/atuin_history_cleanup.py cleanup-typos --db-path ~/.local/share/atuin/history.db --before now --typo-window-seconds 300 --max-typos 20 --backup-dir ~/.local/share/atuin/cleanup-backups/manual-run
70```
71
72 Manual review path:
73 Start with the suggested `atuin search -i --search-mode prefix ...` preview command. The audit will also add `--cwd <cwd>` when it knows the original working directory, so review stays narrow even if your default Atuin config uses `skim` or another fuzzy mode. In the TUI inspector, use `Ctrl+O`, confirm the exact entry, then `Ctrl+D` to delete that one row.
74
755. Stop after the cleanup you actually verified. Do not keep expanding the scope.
76
77## What The Audit Does
78
79- Resolves the database path from `atuin info` unless `--db-path` is provided.
80- Opens the SQLite database in read-only mode and inspects only `id`, `timestamp`, `exit`, `command`, `cwd`, `session`, and `hostname`.
81- Groups duplicates by `(command, cwd, hostname)` and reports how many rows exceed `--dupkeep`.
82- Emits typo review commands with an explicit `--search-mode prefix` override and never emits `atuin search --delete`.
83- `cleanup-typos` first runs the same typo audit, then creates a snapshot, writes `pre_audit.json`, `plan.json`, and `post_verify.json`, and only commits the deletion to remote sync after verification succeeds.
84- Detects typo candidates only when all of these are true:
85 - same session
86 - within the configured window
87 - arguments after the first token are identical
88 - previous command exited non-zero
89 - the first token looks rare
90 - the corrected token is much more common
91 - the token change is a single-edit or adjacent-transposition typo
92- Excludes path- or script-like first tokens from typo suggestions.
93
94## Output Expectations
95
96- `duplicates` gives one global preview/apply pair for `history dedup`.
97- `typos` gives per-row review data: id, time, cwd, original command, suggested correction, reason, and shell-safe preview commands for inspector review only.
98- `--format json` is preferable when another tool needs to post-process the audit.
99- `cleanup-typos` prints a text summary and leaves its backup and verification artifacts in the chosen backup directory.