This PR fixes critical issues with token tracking and provides users with actionable warnings based on real failure data. 1. **Incorrect token counting**: The system was adding cache tokens (cache_creation_input_tokens, cache_read_input_tokens) as if they were new tokens, causing inflated counts like 28125% usage. Cache tokens are cumulative state, not incremental additions. 2. **No user guidance**: Users had no warning when approaching context limits, leading to unexpected "Prompt is too long" errors. - Show only raw token counts from Claude API (input + output) - Remove percentage calculations and context window estimates - Display running totals that users can trust Based on analysis of 29 failed sessions, implemented three warning levels: - β Safe: < 80K tokens - β οΈ Caution: 80K-95K tokens (yellow warning) - π¨ Danger: > 95K tokens (red alert) The lowest observed failure was at 96,800 tokens, so warnings start at 80K to give users ample time to start a new session. - Styled clickable popover (replacing poor native tooltips) - Token breakdown (input/output/total) - Clear warning messages with context - Dark mode support - Fixed `extractTokenUsage()` to only count actual input/output tokens - Removed hardcoded system overhead calculations - Added contextWindowTokens tracking for future use - Updated UI to show raw truth instead of estimates This gives users the information they need without confusing calculations or impossible percentages.
5.5 KiB
Crystal - Multi-Session Claude Code Manager
Crystal is an Electron desktop application that lets you run, inspect, and test multiple Claude Code instances simultaneously using git worktrees. Crystal is an independent project created by Stravu. Stravu provides editable, collaborate AI notebooks with text, tables, diagrams.
https://github.com/user-attachments/assets/e32f0ee7-c25a-43d6-a704-8a39878032eb
The Crystal Workflow
- Create sessions from prompts, each in an isolated git worktree
- Iterate with Claude Code inside your sessions. Each iteration will make a commit so you can always go back.
- Review the diff changes and make manual edits as needed
- Squash your commits together with a new message and rebase to your main branch.
β¨ Key Features
- π Parallel Sessions - Run multiple Claude Code instances at once
- π³ Git Worktree Isolation - Each session gets its own branch
- πΎ Session Persistence - Resume conversations anytime
- π§ Git Integration - Built-in rebase and squash operations
- π Change Tracking - View diffs and track modifications
- π Notifications - Desktop alerts when sessions need input
- ποΈ Run Scripts - Test changes instantly without leaving Crystal
π Quick Start
Prerequisites
- Claude Code installed and logged in or API key provided
- Git installed
- Git repository (Crystal will initialize one if needed)
1. Create a Project
Create a new project if you haven't already. This can be an empty folder or an existing git repository. Crystal will initialize git if needed.
2. Create Sessions from a Prompt
For any feature you're working on, create one or multiple new sessions:
- Each session will be an isolated git worktree
3. Monitor and Test Your Changes
As sessions complete:
- Configure run scripts in project settings to test your application without leaving Crystal
- Use the diff viewer to review all changes and make manual edits as needed
- Continue conversations with Claude Code if you need additional changes
4. Finalize Your Changes
When everything looks good:
- Click "Rebase to main" to squash all commits with a new message and rebase them to your main branch
- This creates a clean commit history on your main branch
Git Operations
- Rebase from main: Pull latest changes from main into your worktree
- Squash and rebase to main: Combine all commits and rebase onto main
- Always preview commands with tooltips before executing
Installation
Download Pre-built Binaries
- macOS: Download
Crystal-{version}.dmgfrom the latest release- Open the DMG file and drag Crystal to your Applications folder
- On first launch, you may need to right-click and select "Open" due to macOS security settings
Building from Source
# Clone the repository
git clone https://github.com/stravu/crystal.git
cd crystal
# One-time setup
pnpm run setup
# Run in development
pnpm run electron-dev
Building for Production
# Build for macOS
pnpm build:mac
π€ Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Developing Crystal with Crystal
If you're using Crystal to develop Crystal itself, you need to use a separate data directory to avoid conflicts with your main Crystal instance:
# Set the run script in your Crystal project settings to:
pnpm run setup && pnpm run build:main && CRYSTAL_DIR=~/.crystal_test pnpm electron-dev
This ensures:
- Your development Crystal instance uses
~/.crystal_testfor its data - Your main Crystal instance continues using
~/.crystal - Worktrees won't conflict between the two instances
- You can safely test changes without affecting your primary Crystal setup
π License
Crystal is open source software licensed under the MIT License.
Third-Party Licenses
Crystal includes third-party software components. All third-party licenses are documented in the NOTICES file. This file is automatically generated and kept up-to-date with our dependencies.
To regenerate the NOTICES file after updating dependencies:
pnpm run generate-notices
Disclaimer
Crystal is an independent project created by Stravu. Claudeβ’ is a trademark of Anthropic, PBC. Crystal is not affiliated with, endorsed by, or sponsored by Anthropic. This tool is designed to work with Claude Code, which must be installed separately.
