> For the complete documentation index, see [llms.txt](https://spuff.avelino.run/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spuff.avelino.run/development.md).

# Development Guide

This directory contains documentation for developing spuff.

## Contents

* [Setup](/development/setup.md) - Development environment setup
* [Testing](/development/testing.md) - Testing strategies and commands
* [Debugging](/development/debugging.md) - Debugging tips and tools
* [Cross-Compilation](/development/cross-compilation.md) - Building the agent for Linux
* [Releasing](/development/releasing.md) - Release process

## Quick Start

```bash
# Clone
git clone https://github.com/avelino/spuff.git
cd spuff

# Build
cargo build

# Test
cargo test --all

# Run
cargo run -- status
```

## Project Structure

```
spuff/
├── src/
│   ├── main.rs              # CLI entry point
│   ├── cli/                 # Command implementations
│   │   ├── mod.rs
│   │   └── commands/
│   │       ├── up.rs        # spuff up
│   │       ├── down.rs      # spuff down
│   │       ├── ssh.rs       # spuff ssh
│   │       └── ...
│   ├── provider/            # Cloud provider abstraction
│   │   ├── mod.rs           # Provider trait
│   │   └── digitalocean.rs  # DigitalOcean implementation
│   ├── connector/           # SSH/network operations
│   │   └── ssh.rs
│   ├── environment/         # Cloud-init and templates
│   │   └── cloud_init.rs
│   ├── agent/               # Remote agent (separate binary)
│   │   ├── main.rs
│   │   ├── routes.rs
│   │   └── metrics.rs
│   ├── tui/                 # Terminal UI
│   │   ├── mod.rs
│   │   ├── progress.rs
│   │   └── widgets.rs
│   ├── config.rs            # Configuration loading
│   ├── state.rs             # SQLite state management
│   ├── error.rs             # Error types
│   └── utils.rs             # Utilities
├── docs/                    # Documentation
├── examples/                # Example configurations
├── tests/                   # Integration tests
├── Cargo.toml
├── CLAUDE.md                # LLM instructions
├── CONTRIBUTING.md          # Contribution guidelines
└── README.md
```

## Key Concepts

### Two Binaries

Spuff produces two binaries:

1. **spuff** - CLI tool that runs on user's machine
2. **spuff-agent** - Daemon that runs on cloud VMs

### Provider Abstraction

Cloud providers implement the `Provider` trait. See [docs/providers/](/providers.md) for details.

### Cloud-Init Templates

VM bootstrapping uses Tera templates. See [docs/adr/0001-cloud-init-bootstrap.md](/adr/0001-cloud-init-bootstrap.md).

### Local State

Instance tracking uses SQLite. See [docs/adr/0003-sqlite-local-state.md](/adr/0003-sqlite-local-state.md).

## Useful Commands

```bash
# Fast compile check (no build)
cargo check

# Format code
cargo fmt

# Lint check
cargo clippy

# Build release
cargo build --release

# Run specific binary
cargo run --bin spuff -- up
cargo run --bin spuff-agent

# Run with logging
RUST_LOG=debug cargo run -- up
RUST_LOG=spuff=trace cargo run -- status
```

## Environment Variables

| Variable             | Description                        |
| -------------------- | ---------------------------------- |
| `DIGITALOCEAN_TOKEN` | DigitalOcean API token             |
| `RUST_LOG`           | Logging level (debug, trace, etc.) |
| `SPUFF_AGENT_TOKEN`  | Agent authentication token         |
| `TS_AUTHKEY`         | Tailscale auth key                 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://spuff.avelino.run/development.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
