Invisible automation layer for Claude Code. Watches your sessions, discovers repeated workflows, suggests automating them.
Project description
Zoku
The invisible automation layer for Claude Code.
Zoku is an open source Claude Code hook that runs silently in the background while you work. It watches every action you take across sessions, discovers repeated patterns in your workflow, and tells you about them so you can automate the boring parts.
You don't configure anything. You don't change how you work. You just install it once and forget about it. Zoku does the rest.
The Problem
Every developer has habits they don't notice. You grep for something, open the file, edit it, run the tests, then fix the lint errors. You do this ten times a day without thinking about it. Multiply that across weeks and you're spending hours on sequences that could be a single command.
The issue is that nobody sits down and audits their own workflow. It's tedious, it's invisible, and honestly most people don't even realize they're repeating themselves.
What Zoku Does
Zoku hooks into Claude Code's event system and records every tool action: file reads, edits, searches, bash commands, everything. It stores these as session traces. When a session ends, Zoku runs a pattern detection algorithm across all your recorded sessions. It looks for contiguous subsequences of tool usage that appear in two or more sessions.
When you start a new session, Zoku loads the patterns it found and injects them into Claude's context. Claude now knows "hey, this user frequently does Grep then Read then Edit then Bash then Bash" and can proactively suggest or execute that workflow.
How the Detection Works
- Every
PostToolUseevent is recorded as anActionwith the tool name, a short input summary, timestamp, and session ID - Actions within a session form a
SessionTrace, which is essentially an ordered list of tool names - The detector extracts all contiguous subsequences of length 3 to 15 from each session
- It counts how many distinct sessions each subsequence appears in
- Subsequences that appear in 2+ sessions become candidate patterns
- Strict subsets of longer patterns are removed (if "A B C" is always part of "A B C D", only the longer one survives)
- Results are sorted by frequency first, then by length
No machine learning, no cloud calls, no external dependencies. Pure algorithmic analysis using Python's standard library.
What Gets Stored
All data lives in a .zoku/ directory (local or global depending on your install):
.zoku/
traces/
2026-04-01_session123.jsonl # one JSONL file per session
2026-04-02_session456.jsonl
prompts/
2026-04-01_session123.jsonl # user prompts per session
patterns.json # discovered workflow patterns
Each line in a trace file is a JSON object:
{"tool": "Grep", "input_summary": "grep:TODO", "timestamp": "2026-04-01T14:30:00+00:00", "session_id": "abc123", "success": true}
{"tool": "Read", "input_summary": "/src/main.py", "timestamp": "2026-04-01T14:30:05+00:00", "session_id": "abc123", "success": true}
{"tool": "Edit", "input_summary": "edit:/src/main.py", "timestamp": "2026-04-01T14:30:15+00:00", "session_id": "abc123", "success": true}
Nothing sensitive is stored. Input summaries are truncated to 200 characters and only contain file paths or command previews, never file contents.
Installation
Quick Install (Recommended)
pip install zoku
python -m zoku setup
That's it. Two commands, zero configuration. Zoku installs globally and works in every project.
Install from Claude Code
Already inside a Claude Code session? Just ask Claude:
Install zoku for me:
pip install zoku && python -m zoku setup
Claude will run it and Zoku starts working immediately — in that session and every future one.
Install from GitHub (latest development version)
pip install git+https://github.com/kasparovabi/zoku.git
python -m zoku setup
Per-Project Install
If you only want Zoku active in a specific project:
pip install zoku
cd your-project
python -m zoku install
This writes to your-project/.claude/settings.json and creates your-project/.zoku/.
Uninstalling
python -m zoku uninstall --global # remove global hooks
python -m zoku uninstall # remove project hooks
python -m zoku clear # delete all recorded data
pip uninstall zoku # remove the package
Usage
There is no usage. That's the point.
Install it and use Claude Code exactly as you always do. Zoku is completely invisible during your sessions. It only surfaces information when:
- A session ends and new patterns are found (logged silently)
- A session starts and previously discovered patterns exist (injected as context for Claude)
CLI Commands
To inspect what Zoku has learned:
python -m zoku status # installation status, session count, pattern count
python -m zoku patterns # list all discovered workflow patterns with details
python -m zoku traces # show recorded sessions and their tool sequences
python -m zoku analyse # force pattern analysis right now (normally happens on session end)
python -m zoku clear # wipe all traces and patterns
Example Output
After a few sessions, python -m zoku patterns might show:
Discovered 3 workflow pattern(s):
Pattern 1: Grep > Read > Edit > Bash > Bash
Steps: Grep -> Read -> Edit -> Bash -> Bash
Seen in: 4 sessions
Example:
1. [Grep] grep:handleSubmit
2. [Read] /src/components/Form.tsx
3. [Edit] edit:/src/components/Form.tsx
4. [Bash] npm test
5. [Bash] npm run lint
Pattern 2: Read > Edit > Read > Edit
Steps: Read -> Edit -> Read -> Edit
Seen in: 3 sessions
Pattern 3: Glob > Read > Edit > Bash
Steps: Glob -> Read -> Edit -> Bash
Seen in: 2 sessions
Architecture
zoku/
__init__.py # package metadata (version 0.1.2)
__main__.py # entry point: python -m zoku
cli.py # 8 CLI commands (setup, install, uninstall, patterns, traces, status, analyse, clear)
recorder.py # Action/SessionTrace dataclasses, JSONL storage, MCP tool normalisation
detector.py # Pattern detection: subsequence extraction, frequency counting, subset pruning
hooks.py # Claude Code hook handlers (PostToolUse, Stop, SessionStart, UserPromptSubmit)
installer.py # Hook registration into .claude/settings.json (local + global)
Hook Integration
Zoku registers four hooks in Claude Code's settings:
| Event | What Zoku Does | Timeout |
|---|---|---|
PostToolUse |
Records tool name, input, response summary, and success/failure | 5s |
Stop |
Loads all traces, runs pattern detection, saves new patterns | 15s |
SessionStart |
Injects patterns as context (also re-injects after compaction) | 5s |
UserPromptSubmit |
Records user prompts for intent-to-action correlation | 3s |
Hooks communicate via stdin/stdout JSON using the hookSpecificOutput protocol. MCP tools (e.g. mcp__github__push_files) are automatically normalised to readable format (github:push_files).
Technical Details
Python Version: 3.10+
External Dependencies: None. Everything uses Python's standard library (json, pathlib, dataclasses, argparse, datetime, shutil).
Test Suite: 67 tests covering all Zoku functionality. Run with:
python -m pytest tests/ -v
Data Safety: Zoku never modifies your code, never sends data anywhere, and never interferes with Claude Code's normal operation. It only reads hook events and writes to its own .zoku/ directory.
Roadmap
This project is part of a larger vision for AI coding tool infrastructure:
Zoku v2: Workflow replay (not just detection, but execution), cross project pattern aggregation, pattern sharing between team members
AgentBlackBox: SaaS audit trail for AI agent sessions. Full token cost tracking, decision tree visualization, compliance reporting for enterprises that need to prove what their AI agents did and why.
MirrorMode: Cross agent workflow translation. Record a workflow in Claude Code, replay it in Cursor or Aider. Universal session format that works across all AI coding tools.
Contributing
This project is in active development. If you're interested in contributing, the codebase is intentionally simple and well tested. Every module is under 200 lines and uses no external dependencies.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zoku-0.1.2.tar.gz.
File metadata
- Download URL: zoku-0.1.2.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcaca84805dd2172f937a17c67edc95016b28027ad10e943df084a60014dc3ba
|
|
| MD5 |
67e70b2a9a96d61b008cd0ce578cd46f
|
|
| BLAKE2b-256 |
f6bf5fbd9733ed82fd8e640703c26ad0da62e9982446d3ae8c351957f310bba4
|
Provenance
The following attestation bundles were made for zoku-0.1.2.tar.gz:
Publisher:
publish.yml on kasparovabi/zoku
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zoku-0.1.2.tar.gz -
Subject digest:
dcaca84805dd2172f937a17c67edc95016b28027ad10e943df084a60014dc3ba - Sigstore transparency entry: 1233099646
- Sigstore integration time:
-
Permalink:
kasparovabi/zoku@08e8e5a05fe768132657bd63f7cf605b80368083 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/kasparovabi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08e8e5a05fe768132657bd63f7cf605b80368083 -
Trigger Event:
release
-
Statement type:
File details
Details for the file zoku-0.1.2-py3-none-any.whl.
File metadata
- Download URL: zoku-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0548f308c8f1683092f616d614ad66c41b803a1ac338a2921160b790ce371db2
|
|
| MD5 |
9e4662e9edce70878d31faa0d017feb5
|
|
| BLAKE2b-256 |
e254036434efaf31bd71746679cfbde7f180e35ada1e734548317f005e7a7eb1
|
Provenance
The following attestation bundles were made for zoku-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on kasparovabi/zoku
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zoku-0.1.2-py3-none-any.whl -
Subject digest:
0548f308c8f1683092f616d614ad66c41b803a1ac338a2921160b790ce371db2 - Sigstore transparency entry: 1233099948
- Sigstore integration time:
-
Permalink:
kasparovabi/zoku@08e8e5a05fe768132657bd63f7cf605b80368083 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/kasparovabi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08e8e5a05fe768132657bd63f7cf605b80368083 -
Trigger Event:
release
-
Statement type: