codex-blocker
v0.1.1
Published
Automatically blocks distracting websites unless Codex is actively running. Forked from Theo Browne's (T3) Claude Blocker
Maintainers
Readme
codex-blocker
CLI tool and server for Codex Blocker — block distracting websites unless Codex is actively running.
Installation
npm install -g codex-blocker
# or
npx codex-blockerQuick Start
# Optional setup info
npx codex-blocker --setupUsage
# Start server (default port 8765)
npx codex-blocker
# Show setup info
npx codex-blocker --setup
# Custom port
npx codex-blocker --port 9000
# Remove setup (no-op)
npx codex-blocker --remove
# Show help
npx codex-blocker --help
# Show version
npx codex-blocker --versionHow It Works
Codex sessions — The server tails Codex session logs under
~/.codex/sessionsto detect activity. It marks a session “working” on your prompt and “idle” on the final assistant reply (tool calls don’t count as idle).Server — Runs on localhost and:
- Tracks active Codex sessions
- Marks sessions "working" when new log lines arrive
- Broadcasts state via WebSocket to the Chrome extension
Extension — Connects to the server and:
- Blocks configured sites when no sessions are working
- Shows a modal overlay (soft block, not network block)
- Updates in real-time without page refresh
API
HTTP Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| /status | GET | Returns current state (sessions, blocked status) |
WebSocket
Connect to ws://localhost:8765/ws to receive real-time state updates:
{
"type": "state",
"blocked": true,
"sessions": 1,
"working": 0
}Programmatic Usage
import { startServer } from 'codex-blocker';
// Start on default port (8765)
startServer();
// Or custom port
startServer(9000);Requirements
- Node.js 18+
- Codex CLI
License
MIT
