Contributing to StackAI CLI

This guide covers the local development workflow for the StackAI CLI. You do not need to publish or install the CLI to test changes.

Table of Contents


Prerequisites

Required Tools

Tool
Version
Installation

Rust

1.85.0+

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

cargo-audit

Latest

cargo install cargo-audit --locked

cargo-deny

Latest

cargo install cargo-deny --locked

Tool
Purpose
Installation

bacon

Background code checker (replaces cargo-watch)

cargo install bacon

cargo-nextest

Faster test runner (3x faster)

cargo install cargo-nextest

cargo-machete

Dead code detection

cargo install cargo-machete

⚠️ Note: cargo-watch was archived in January 2025. Use bacon instead for file watching.


Quick Start


Using Cargo Aliases

The project defines convenient aliases in .cargo/config.toml. Use these instead of typing full commands:

Quality Checks

Testing

CI Commands

Development

Documentation

Dependencies

Building for Production


Local Development Workflow

Method 2: Build and Run Binary

Method 3: Install Locally

Fast Iteration with Bacon

Baconarrow-up-right is the modern replacement for cargo-watch:

Create a bacon.toml for custom jobs:

Then run bacon run-status or bacon run-doctor.


Testing Strategy

Unit Tests

Documentation Tests

⚠️ Important: cargo-nextest does NOT run doctests. Run them separately:

Using cargo-nextest (3x Faster)

Integration Testing for CLI Commands

For testing CLI output, consider adding these dev-dependencies:

Example integration test with assert_cmd:


Code Quality Checks

Full CI Check (What the Pre-commit Hook Runs)

Individual Checks


Safe Testing (Isolated Environment)

⚠️ Never modify your real ~/.config/stackai/ during development!

Use XDG_CONFIG_HOME for Isolation

The CLI uses directories-next which respects XDG_CONFIG_HOME:

Test Script

Create a helper script for isolated testing:

Usage:

Testing Docker-Dependent Commands

Some commands require Docker. Mark tests appropriately:

Run Docker-dependent tests explicitly:


Adding a New Command

1. Define in cli.rs

2. Create Implementation

3. Export in mod.rs

4. Wire Up Dispatch

In main.rs or the parent command handler, add the match arm.

5. Add Tests

6. Test Locally


Pull Request Workflow

Branch Naming

Use descriptive branch names:

Commit Messages

Use Conventional Commitsarrow-up-right:

Before Pushing

PR Checklist


Debugging Tips

Enable Debug Logging

Debug Output in Code

VS Code Debugging

Add to .vscode/launch.json:


Build Performance

Linker (Linux)

✅ As of Rust 1.90.0 (September 2025), LLD is the default linker on x86_64-unknown-linux-gnu. No configuration needed!

For even faster linking on Linux, use mold:

Linker (macOS)

On macOS, consider sold (mold's macOS version):

Reduce Debug Info

Add to Cargo.toml for faster debug builds:

Incremental Compilation

Debug builds use incremental compilation by default. For fastest iteration:


Common Issues

"Docker daemon not running"

"Permission denied" for Docker

Clippy Warnings

Test Failures

Pre-commit Hook Failures

Build Cache Issues


Project Structure


Getting Help

  • 📖 Read AGENTS.md for architecture decisions

  • 🔍 Check existing GitHub issues

  • 💬 Ask on Slack

  • 📧 Contact the team


Happy hacking! 🦀

Last updated

Was this helpful?