# Repository Briefing: context-machine-lab/sleepless-agent
> Source: https://repoforai.com/repo/context-machine-lab/sleepless-agent (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/context-machine-lab/sleepless-agent
- **Official Docs / Website**: https://context-machine-lab.github.io/sleepless-agent/
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: B (53/100 · Maintenance 6/35 · Adoption 16/25 · Releases 11/20 · License 20/20)
- **Latest Release**: v0.1.2 (2025-10-27) — https://github.com/context-machine-lab/sleepless-agent/releases
- **Review Snapshot**: 2026-12-04
- **Deployment / Stack Signals**: Self-Hosted, CLI
- **Momentum**: 843 ★ total (+0 24h / +3 7d) · 111 forks
- **Topics**: `ai-agent`, `anthropic`, `automation`, `autonomous-agents`, `claude`, `claude-code`, `daemon`, `git-automation`, `python`, `slack`, `slack-bot`, `sqlite`
- **When to Use**: Best for: Individual developers and small teams already using Claude Code who want to queue trusted, non-urgent work and review the results in Git later. Skip if: You require offline inference, interchangeable model backends, a shared multi-node worker service, or sandboxed execution of tasks from untrusted users.

## Overview
```text
### Architecture & Core Mechanics
Sleepless Agent is a self-hosted Python daemon with two front ends: the `sle` CLI and an optional Slack app using Socket Mode. Task submissions go into a persistent SQLite queue. The daemon event loop schedules work, the Python Agent SDK drives the Claude Code CLI in per-task workspaces, and the result manager saves outputs and metadata. Git automation handles commits and, when configured, pull requests. Threaded Slack chat is a separate interactive path that can read and edit files in a project workspace.

The package requires Python 3.11+ and lists `anthropic`, `slack-sdk`, `sqlalchemy`, `aiosqlite`, `python-dotenv`, `PyYAML`, and `gitpython` among its dependencies. Persistent state includes `tasks.db`, results, reports, logs, and metrics under `workspace/data/`; task and project workspaces live separately. The integrations are Slack Socket Mode and the Claude Code SDK/CLI path. This is not a documented MCP server, plugin interface, or provider-neutral model router.

### Key Capabilities & Differentiators
The dividing line between lightweight and reviewable work is explicit: `sle think` captures an idea, while `-p` assigns a task to a project. Ideas are auto-committed to `thought-ideas`; project work uses feature branches and can be handed off as a PR. The Planner, Worker, and Evaluator stages can be enabled independently and each defaults to a maximum of three turns. The supported execution backend is Claude Code; there is no documented model matrix or alternate backend.

The scheduler checks usage through `claude /usage`. Defaults are a 96% night threshold from 01:00 to 09:00 and a 95% daytime threshold. At the threshold, automatic task generation pauses, pending work waits, and active work finishes; execution resumes after the usage reset. These thresholds govern scheduling, not hard spending or usage caps. `sle check`, `sle usage`, and `sle report` expose operating state and results. Slack chat retains conversation history within a dedicated thread and times out after 30 minutes of inactivity.

### Trade-offs & Limitations
Compared with opening Claude Code directly, this wrapper adds unattended scheduling, durable task state, and a Git-based handoff, at the cost of another long-running process and more credentials to manage. Compared with a conventional CI workflow, it is better suited to open-ended work submitted in natural language. CI is the better fit for repeatable checks with explicit steps and pass/fail criteria; keep those checks on the PRs the agent produces.

SQLite simplifies deployment, but the documented design is a local daemon, not a demonstrated multi-node worker service. Separate workspaces reduce file collisions but are not evidence of a security sandbox. At this alpha stage, start with trusted users and a narrowly scoped repository, restrict Slack access and Git write permissions, and enforce review on protected branches. The Evaluator stage does not replace those controls, and the scheduler's reliance on Claude Code usage reporting makes that integration an operational dependency.

### Hardware & Deployment Guide
Install `sleepless-agent` in a Python 3.11+ environment, install the Claude Code CLI via npm with Node.js, authenticate with `claude login`, and start `sle daemon`. Git supports automatic commits; `gh` is optional for PR automation. A CLI-only setup needs no Slack credentials. To add Slack, enable Socket Mode, configure commands and any chat events you need, and provide the bot and app tokens through `.env` or the process environment. Configure the remote repository before enabling remote Git automation.

Self-hosting covers the daemon and its local state, not model inference. This path still needs access to Claude, but it does not require a separate Claude API key. Run it on a host that can stay up and preserve its workspace and database across restarts; size CPU, memory, and disk for concurrent sessions and any builds or tests they invoke. Release v0.1.0 published the package on PyPI, v0.1.1 was an architectural and documentation overhaul, and v0.1.2 added `requests` as a dependency.
```

## Key Capabilities
```text
- Execution flow: Slack and `sle` feed a persistent SQLite queue; a Python daemon runs Claude Code tasks and stores results.
- Usage scheduling: Configurable day and night thresholds default to 95% and 96%; pending work waits at the threshold while running tasks finish.
- Task separation: Parallel tasks get separate workspaces; ideas are committed to `thought-ideas`, while project tasks use feature branches and can open PRs.
- Workflow control: Planner, Worker, and Evaluator can each be disabled or assigned a turn limit; the defaults are three turns per stage.
- Slack integration: Socket Mode supports slash commands and threaded chat with workspace file edits and a 30-minute idle timeout.
- Operations: `sle check`, `sle usage`, and `sle report` expose queue health, plan usage, and task results; database and results paths can be overridden.
```

## Quick Start / Clone
```bash
pip install sleepless-agent
```
