Zat
English · 中文
What's Zat?
Zat (Zed Agent Thread Manager) is a standalone command-line tool for managing Zed Agent threads. It provides functionality to view, migrate, export, import, and restore threads from the agent's database.
Installation
pip install zat-man
Back up before use
⚠️ WARNING:
zatreads and writes Zed's thread database directly. Although all write operations are protected by transactions and automatic snapshots, mistakes, bugs, or unexpected failures can still cause data loss. Complete a backup before your first write operation, and make sure you know how to restore it.
Manual backup:
-
Quit Zed completely.
-
Copy the entire Zed data directory:
{data_dir}/threads— full thread contents{data_dir}/db— sidebar metadata
Platform data_dir: Windows
%LOCALAPPDATA%\Zed; macOS~/Library/Application Support/Zed; Linux~/.local/share/zed
Manual restore:
- Quit Zed completely.
- Copy the backup directory back to its original location.
Core Workflow
This section demonstrates the core capabilities of zat through a common workflow.
1. Checking the Status
Use the list (or ls) command to inspect the current state of all threads. It groups threads by project and highlights any anomalies.
$ zat ls
Project: C:\Users\foo\Desktop\project1 3 thread(s)
┏━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Status ┃ Hash ┃ Title ┃ Updated ┃
┡━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ 💬 │ 3f9a2c81 │ Fix login crash logic │ 2026-08-09 │
│ 💬 │ 7b1e04d2 │ Refactor cache layer │ 2026-08-09 │
│ 💬 │ d4e8b9f0 │ Add dark mode support │ 2026-08-09 │
└────────┴──────────┴─────────────────────────────────────────┴────────────┘
Orphaned threads (path does not exist; recover with move):
⚠️ a7c21e9d ...from ['C:\\Users\\foo\\Desktop\\legacy-project']
The output reveals an "orphaned" thread, marked with ⚠️. This indicates that its associated project path, C:\Users\foo\Desktop\legacy-project, no longer exists on the file system, likely because the project directory was moved or renamed.
2. Correcting the Path
We can use the move (or mv) command to fix this orphaned thread by associating it with the new project path. move can target threads by their unique hash prefix or by their old project path.
Before performing any write operation, zat checks if the Zed process is running to ensure database consistency.
$ zat mv a7c21e9d C:\Users\foo\Desktop\project1
[ERROR] Please quit Zed first
After quitting Zed, run the command again.
$ zat mv a7c21e9d C:\Users\foo\Desktop\project1
[SUCCESS] Moved 1 thread(s).
Running zat ls again will show that the thread has been successfully moved to the new project, and its orphaned status is resolved.
3. Auditing and Restoring Operations
All write operations (like move, import, and restore) automatically create a checkpoint before execution. We can list these checkpoints at any time.
$ zat chkpt list
ID chkpt-20260809T120000.123456Z-save-3c84
created 2026-08-09 20:00:00.123 +08:00
source manual (save)
channel stable
command chkpt save
---------------------------
ID chkpt-20260809T120500.123456Z-move-a7c2
created 2026-08-09 20:05:00.123 +08:00
source auto (move)
channel stable
command mv a7c21e9d C:\Users\foo\Desktop\project1
If you are not satisfied with the move operation, you can use the checkpoint ID to restore the database to its state before the operation was performed.
$ zat chkpt restore chkpt-20260809T120500.123456Z-move-a7c2
This checkpoint system provides a reliable rollback mechanism for all critical operations. It is also recommended to manually run zat chkpt save to create an explicit baseline before performing complex tasks.
Migration and Archiving
zat also supports data migration across devices or projects.
1. Exporting Data
The export command packages specified threads (or all threads) into a self-contained .zth file. This file contains the full thread content and metadata but excludes any local file paths, making it highly portable.
$ zat export --to threads-archive.zth --markdown
[SUCCESS] Exported 12 thread(s) to threads-archive.zth
[SUCCESS] Markdown written to threads-archive-markdown.zip (12 file(s))
The --markdown option generates an additional ZIP archive containing human-readable Markdown files for each thread, suitable for offline browsing and archiving.
2. Importing Data
On another machine or system, use the import command to inject threads from a .zth file into a specified project path.
$ zat import --from threads-archive.zth --to C:\work\new-project
[SUCCESS] Imported 12 thread(s) into C:\work\new-project
The import process includes strict data validation and conflict detection to ensure the integrity of the target database is not compromised.
Command Reference
-
Query & Diagnostics
zat list [--project PATH] [--all] [--json](alias:ls)zat doctor
-
Data Modification
zat move --from <hash|path> --to NEW_PATH(alias:mv <src> <dst>)zat delete <ID>...(alias:rm)
-
Import & Export
zat export [--from <hash|path>] [--to OUT_FILE] [--markdown]zat import --from FILE --to DIR
-
Checkpoint Management
zat chkpt list(alias:ls)zat chkpt save [--dir PATH]zat chkpt restore [ID_OR_PATH]zat chkpt delete <ID>...(alias:rm)
Development
The environment and dependencies are managed with uv.
# Install dependencies
uv sync
# Run the test suite
uv run pytest
# Run the CLI from source
uv run zat --help
For details on the testing strategy and coverage, see docs/TESTING.md.
License
Metadata
Release files for zat-man 2026.8.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zat_man-2026.8.11.tar.gz | 106.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zat_man-2026.8.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 153.7 kB
Release files / zat_man-2026.8.11.tar.gz
| Download URL | zat_man-2026.8.11.tar.gz |
|---|---|
| Size | 106.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf9dfa27e62bbc4844b32aff7c2d01dc4957d88c0048fc2045b2e63810d2aea6
|
|
BLAKE2b-256 checksum How to use checksums |
ae2887d7b5cb541db2599506591b457e7485e45f9dd641b0a98b382fb18956a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / zat_man-2026.8.11-py3-none-any.whl
| Download URL | zat_man-2026.8.11-py3-none-any.whl |
|---|---|
| Size | 47.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62ed66ab8b4612097f00c1b690a69637130f48375b7b38ffd3f5931eaeb022c7
|
|
BLAKE2b-256 checksum How to use checksums |
976e02be3299c34bcf6f0711d337bebeb879a8e01d682489787fde4fc0dcce77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|