Documentation
Everything you need to know about sustn — the background conductor for AI coding agents that continuously improves your codebase.
What is sustn?
sustn is a native macOS desktop application that acts as a background conductor for AI coding agents. Instead of waiting for you to open a terminal and type a prompt, sustn continuously monitors your repositories, identifies improvements, and executes them autonomously — all using your existing Claude Code subscription.
Every change lands as a branch. Nothing touches your main branch without your explicit approval. You review the work, create a pull request with one click, and merge when you're ready.
Core Philosophy
Every AI coding tool today follows the same pattern: you prompt, it responds. This reactive model means the agent only works when you're actively driving it. When you're not prompting, your subscription tokens go unused. The backlog grows.
sustn takes a different approach. It's proactive. The agent understands your codebase. It maintains a living backlog of improvements. It picks up work when budget is available and delivers results you can approve or discard. You stay in control, but you're no longer the bottleneck.
Two-pass scanning identifies dead code, missing tests, security gaps, tech debt, and more.
Plan → implement → review workflow runs automatically with retry logic and error handling.
Every change lands on a feature branch. Main is never touched without your approval.
Monitors your Claude subscription usage and works only when tokens are available.
Visual task board with drag-and-drop prioritization, categories, and effort estimates.
Native macOS notifications and sound effects keep you informed without interrupting flow.
Getting Started
Get up and running with sustn in under five minutes. This guide walks you through prerequisites, installation, and your first project setup.
Prerequisites
sustn requires the following tools installed on your machine:
Version control. Required for branch management and repository operations.
git --versionThe Claude Code command-line tool. sustn uses this to invoke the AI agent for scanning and code generation.
claude --versionUsed for authentication, creating pull requests, and interacting with GitHub repositories.
gh --versionRequired for building and running the application from source.
node --versionInstallation
Download the latest sustn release for macOS. The app ships as a standard .dmg installer.
git clone https://github.com/sustn/sustn.git
cd sustn
nvm use 22
pnpm install
pnpm tauri:devThe application supports three build environments:
| Command | Environment | Identifier |
|---|---|---|
pnpm tauri:prod | Production | app.sustn.desktop |
pnpm tauri:dev | Development | app.sustn.desktop.dev |
pnpm tauri:qa | QA / Testing | app.sustn.desktop.qa |
Onboarding
When you first launch sustn, you'll be guided through a four-step onboarding flow:
Connect your GitHub account. sustn uses GitHub OAuth to authenticate and interact with your repositories. Your credentials are stored securely in the local SQLite database.
sustn automatically verifies that Git, Claude CLI, and GitHub CLI are installed and properly configured. If anything is missing, you'll see clear instructions to resolve it.
Point sustn at a local repository or clone a remote one. You can add as many repositories as you like — each one becomes a managed project in your sidebar.
That's it. sustn will immediately offer to run your first scan. From here, the agent takes over — finding improvements and adding them to your backlog.
Core Concepts
Understanding these foundational concepts will help you get the most out of sustn.
Projects & Repositories
A project in sustn corresponds to a Git repository on your machine. Each project has its own task backlog, scan history, and configuration. Projects appear in the sidebar and can be reordered by dragging.
When you add a project, sustn tracks:
- The local filesystem path to the repository
- The default branch (usually
mainormaster) - The base branch for creating feature branches
- The remote origin URL
- When the project was last scanned and worked on
Tasks & the Backlog
Tasks are the fundamental unit of work in sustn. Each task represents a specific improvement or fix that the agent has identified (or that you've manually created). Tasks have two origins:
Discovered automatically by the scanner. The agent analyzed your codebase and identified this as a worthwhile improvement.
Created by you. Add tasks directly when you know what needs doing but want the agent to handle the implementation.
The Agent Engine
The engine is the core runtime that coordinates all automated work. Built in Rust, it manages the lifecycle of scanning and task execution through several specialized modules:
ScannerAnalyzes your codebase to discover improvement opportunities using a two-pass system.
PrioritizerScores and ranks projects and tasks to determine what to work on next.
SchedulerControls when the agent is allowed to work based on your time and schedule preferences.
WorkerExecutes tasks through the plan → implement → review workflow.
BudgetMonitors your Claude subscription usage to ensure sustn only works when tokens are available.
GitManages branches, commits, diffs, and pull request creation.
The engine runs as a managed state within the Tauri application, communicating with the frontend through IPC commands and event emitters.
Budget Management
sustn is designed to use your existing Claude Code subscription — specifically the tokens you're not using. It reads Claude's usage statistics and calculates how many tokens are available for background work.
The budget module reads from Claude's stats-cache.json file, which tracks daily token consumption. When tokens are exhausted, sustn gracefully pauses until more budget becomes available.
Scanning & Discovery
Scanning is how sustn builds your task backlog. The scanner analyzes your entire codebase and identifies concrete improvements — from missing test coverage to security vulnerabilities.
How Scanning Works
sustn uses a sophisticated two-pass scanning system to balance speed with depth:
- Walks directory tree (skips node_modules, .git, etc.)
- Pre-reads source files up to size limits
- Invokes Claude for rapid analysis
- Returns results immediately to UI
- Takes seconds to minutes
- Runs in the background after Pass 1
- Full Claude reasoning with tool use
- Deeper analysis of each finding
- Results saved directly to database
- More thorough but budget-aware
What Gets Detected
The scanner identifies improvements across nine categories:
| Category | Weight | Examples |
|---|---|---|
| Security | 5.0 | Input validation gaps, hardcoded secrets, dependency vulnerabilities |
| Tests | 3.0 | Missing unit tests, untested edge cases, low coverage areas |
| Tech Debt | 2.0 | Dead code, deprecated APIs, code duplication |
| Performance | 2.0 | N+1 queries, unnecessary re-renders, unoptimized assets |
| Feature | 1.5 | Missing functionality, incomplete implementations |
| DX | 1.5 | Poor error messages, missing type definitions, confusing APIs |
| General | 1.5 | Code quality, readability, best practice violations |
| Observability | 1.5 | Missing logging, monitoring gaps, error tracking |
| Docs | 1.0 | Outdated comments, missing JSDoc, stale README |
Category weights are used by the prioritizer to rank tasks. Security issues are weighted 5x more heavily than documentation improvements, ensuring critical fixes surface first.
Scan Frequency
Configure how often sustn scans your repositories:
On PushScan whenever new commits are pushed to the repository.Every 6hScan four times per day on a rolling schedule.Every 12hScan twice per day.DailyScan once per day, typically at the start of your work window.ManualOnly scan when you explicitly click the scan button.Task Management
The task system is at the heart of sustn. It's where discovered improvements are tracked, prioritized, and managed through their entire lifecycle.
Task Lifecycle
Every task moves through a defined set of states:
| State | Description |
|---|---|
| pending | Waiting in the backlog. The agent hasn't started working on this task yet. |
| in_progress | The agent is actively working — planning, implementing, or reviewing. |
| review | Work is complete. The changes are on a branch, ready for your review. |
| done | You've approved the work. The PR has been merged or the task is resolved. |
| failed | The agent couldn't complete the work after maximum retries. |
| dismissed | You've decided this task isn't worth pursuing. The branch is cleaned up. |
Task Properties
Each task carries detailed metadata to help you understand and manage it:
TitleA concise description of the improvement.DescriptionDetailed explanation of what needs to change and why.CategoryClassification (security, tests, tech_debt, performance, etc.).Priority1 (critical) through 5 (trivial), set by the scanner or manually.EffortLow, medium, or high — helps plan which tasks to tackle first.FilesList of files the agent identified as relevant to the task.BranchThe Git branch where work will be (or has been) done.Commit SHAThe commit hash of the completed work.Tokens UsedHow many Claude tokens were consumed for this task.Retry CountNumber of implementation attempts (max 2 retries).PR URLLink to the GitHub pull request, if created.NotesYour own notes and constraints for the agent to consider.Prioritization
sustn's prioritizer uses a multi-factor scoring system to decide what to work on next. Both projects and tasks are scored independently.
- User-set priority (1-5)
- Hours since last work (staleness)
- Number of pending tasks
- Highest task priority in backlog
- Tasks completed today (negative)
- Priority (1-5 from scanner)
- Category weight (security=5x, tests=3x)
- Days since created (age bonus)
- Estimated effort level
- Manual user override
You can override automatic prioritization at any time by dragging tasks to reorder them or setting manual priorities.
Automated Execution
When the scheduler and budget allow, the engine's worker module picks up tasks and executes them through a structured three-phase workflow.
Work Phases
Every task goes through three distinct phases, each with a 30-minute timeout:
Claude reads the task description, examines the relevant files, and develops a plan of attack. It understands the codebase context, identifies dependencies, and scopes the exact changes needed.
Claude writes the code. It creates or modifies files, adds tests if appropriate, and commits the changes to the feature branch. The output includes a list of modified files, a summary of changes, and any tests added.
Claude self-reviews the implementation. It checks for correctness, style consistency, potential issues, and whether the original task requirements were fully addressed. The review outputs a pass/fail verdict with detailed feedback.
// Implementation output
{
files_modified: ["src/auth/middleware.ts", "src/auth/middleware.test.ts"],
summary: "Added input validation to auth middleware...",
tests_added: true
}
// Review output
{
passed: true,
feedback: "Implementation correctly addresses the task...",
issues: []
}Retry & Error Handling
If the review phase fails or an error occurs during implementation, the worker automatically retries up to 2 times. Each retry includes the error feedback from the previous attempt, giving Claude context to fix its approach.
On failure, the branch is cleaned up and the agent returns to the original branch. The error details are stored in the task's lastError field for debugging.
Code Review & Pull Requests
Once the agent completes a task, the changes land on a feature branch. sustn provides a full code review experience right inside the app.
Diff Viewer
The built-in diff viewer shows exactly what changed, presented in a familiar side-by-side format:
- Changed files sidebar — Browse all modified files with addition/deletion stats
- Side-by-side diff — View old and new code next to each other with syntax highlighting
- File content viewer — Read the full file with syntax highlighting for deeper context
- Lines added/removed — Quick stats on the scope of changes
react-diff-view library for a GitHub-quality code review experience, with unified or split-view modes.Creating Pull Requests
When you're satisfied with the agent's work, you can create a pull request with one click. sustn uses the GitHub CLI under the hood, so the PR appears in your repository just like any other.
Examine the changes in the built-in diff viewer. Make sure everything looks correct.
Click 'Push' to push the feature branch to your remote. sustn handles the git push with upstream tracking.
Click 'Create PR' and sustn opens a pull request on GitHub with a title and description derived from the task.
Auto-create PRs setting to have sustn automatically create pull requests when tasks are completed — no manual step required.Configuration
sustn is highly configurable. Global settings apply to all projects by default, and individual projects can override specific settings.
General Settings
| Setting | Default | Description |
|---|---|---|
| Notifications | Enabled | Desktop notifications for scan completions, task ready for review, errors. |
| Sound Effects | Enabled | Audio feedback for events. Three presets: chime, ding, pop. |
| Auto-create PRs | Disabled | Automatically open a GitHub PR when a task completes. |
| Delete branch on dismiss | Enabled | Clean up the feature branch when you dismiss a task. |
Git & Branch Settings
| Setting | Options | Description |
|---|---|---|
| Branch Prefix | sustn/ custom/ none | Prefix added to all feature branches created by the agent. |
| Branch Name Style | slug short-hash task-id | How the branch name is generated from the task title. |
| Default Base Branch | main | The branch from which feature branches are created. |
| Remote Origin | origin | The git remote used for push and PR operations. |
# slug style (default)
sustn/add-error-handling-to-auth-middleware
# short-hash style
sustn/a3f8b2
# task-id style
sustn/task-01j8k2m4n5Scheduling
Control exactly when the agent is allowed to work. Three scheduling modes are available:
The agent can work 24/7 as long as budget is available. Best for non-critical repositories where you want maximum throughput.
Set specific days and a time range. Supports overnight windows (e.g., 22:00–06:00). Ideal for working while you sleep.
Schedule: Mon-Fri, 22:00 - 06:00
Timezone: America/New_YorkThe agent only works when you explicitly start a task. Full manual control over when work happens.
Budget Controls
| Setting | Default | Description |
|---|---|---|
| Budget Ceiling % | 80% | Maximum percentage of your weekly Claude token budget that sustn can use. |
| Reserve % | 10% | Tokens reserved for your personal interactive Claude use. |
| Show in Sidebar | Yes | Display remaining budget in the sidebar status card. |
Per-Project Overrides
Any global setting can be overridden on a per-project basis. This lets you apply different strategies to different repositories:
- Agent Preferences — Free-form text instructions that Claude considers when working on this project (e.g., "Always use TypeScript strict mode").
- Scan Preferences — Custom instructions for how the scanner should analyze this project (e.g., "Focus on test coverage").
- Base Branch — Override the default base branch for this project.
- Remote Origin — Use a different git remote.
- Budget Ceiling — Set a project-specific token limit.
Architecture
For contributors and technically curious users, here's a deep dive into how sustn is built.
Tech Stack
- React 19 + TypeScript 5
- Vite 6 (build tool)
- Tailwind CSS 3
- shadcn/ui (component library)
- TanStack Query v5 (async state)
- Zustand v5 (client state)
- React Router v6 (routing)
- Tauri v2 (native shell)
- Rust (backend logic)
- SQLite (database)
- Claude CLI (AI agent)
- GitHub CLI (git operations)
Data Flow
Data flows through the application in a predictable pattern:
The Tauri IPC layer provides type-safe communication between the React frontend and Rust backend. Events flow bidirectionally — the backend emits events (like scan progress) that the frontend subscribes to through TanStack Query's event integration.
Engine Modules
The agent engine is built from six specialized Rust modules, each with a clear responsibility:
engine/
├── mod.rs Core EngineState, Claude CLI invocation
├── scanner.rs Two-pass codebase analysis
├── worker.rs Task execution (plan → implement → review)
├── scheduler.rs Time window & schedule validation
├── prioritizer.rs Project & task scoring algorithms
├── budget.rs Token usage tracking & budget calculations
├── git.rs Git operations wrapper
└── db.rs Direct database operations from RustThe engine state is managed as a thread-safe singleton using Arc<EngineState>, shared across all Tauri command handlers. It tracks the current running status, active task, and cancellation token for the scheduler loop.
pub struct EngineState {
pub running: RwLock<bool>,
pub current_task: Mutex<Option<CurrentTask>>,
pub cancel_token: Mutex<Option<CancellationToken>>,
}Claude CLI is invoked as a subprocess with the --print and --output-format json flags, enabling structured output parsing. Each invocation has a 30-minute timeout to prevent runaway processes.