smart-tree
CLAUDE.md270 starsChanged 10 months agoMITView on GitHub
Smart Tree (st) is a fast, AI-friendly directory visualization tool written in Rust. It provides 30+ MCP tools for AI assistants and is 10-24x faster than traditional tree. Run ./scripts/manage.sh test before opening a PR — it is the canonical pre-commit gate. Async tests use #[tokio::test]; for verbose diagnostics use RUST_LOG=debug cargo test -- --nocapture. After rebuilding, if st --version hangs, run hash -r to clear your shell's binary cache. Thin-client + daemon model: The st CLI binary is a…
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 24
Run ./scripts/manage.sh test before opening a PR — it is the canonical pre-commit gate.
- Very specific: line 26
After rebuilding, if st --version hangs, run hash -r to clear your shell's binary cache.
- Very specific: line 36
Exclusive modes: run locally and exit: --mcp, --version, --completions, --man, --security-scan, --terminal, --dashboard, --http-daemon, …
- Distinctive: line 116
Default features: none (minimal build)
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Smart Tree (st) is a fast, AI-friendly directory visualization tool written in Rust. It provides 30+ MCP tools for AI assistants and is 10-24x faster than traditional tree.
Build & Development Commands
cargo build # Debug build
cargo build --release # Release build (LTO enabled, stripped)
cargo test # Run all tests
cargo test --release # Run performance tests
cargo test <test_name> # Run a single test
cargo run --bin st -- --help # Run locally without installing
cargo fmt # Format code
cargo clippy -- -D warnings # Lint (zero-warning policy)
./scripts/manage.sh test # Pre-commit bundle: test + clippy + fmt --check
./scripts/build-and-install.sh # Build and install locally (clears shell cache)Run ./scripts/manage.sh test before opening a PR — it is the canonical pre-commit gate. Async tests use #[tokio::test]; for verbose diagnostics use RUST_LOG=debug cargo test -- --nocapture.
After rebuilding, if st --version hangs, run hash -r to clear your shell's binary cache.
Architecture
Thin-client + daemon model: The st CLI binary is a thin client that spawns an async daemon (std) for heavy lifting and persistent state. The daemon exposes an HTTP API on port 28428 (default).
CLI → Daemon Flow
Most st commands follow this path:
main.rsparses CLI args, initializes logging- Exclusive modes run locally and exit:
--mcp,--version,--completions,--man,--security-scan,--terminal,--dashboard,--http-daemon,--guardian-daemon, daemon control flags - Everything else (the common case): auto-starts daemon if needed, builds a
CliScanRequest(defined indaemon_cli.rs), sends HTTP POST to/cli/scan, prints response
Daemon Communication
- CLI ↔ Daemon: HTTP/JSON on port 28428, authenticated via Bearer token stored at
~/.st/daemon.token - Daemon ↔ Daemon:
st-protocolbinary wire protocol (6502-inspired opcodes) over Unix sockets — this is NOT used for CLI-daemon communication - Auto-spawn:
DaemonClient::ensure_running()spawns daemon in background withsetsid(Unix) orDETACHED_PROCESS(Windows), retries with exponential backoff (5 attempts, 100ms→1600ms)
MCP Integration (two modes)
- Stdio (
st --mcp): JSON-RPC 2.0 over stdin/stdout, used by Claude Desktop and other MCP clients. Entry:McpServer::run_stdio()insrc/mcp/mod.rs - HTTP (via daemon): REST endpoints at
/mcp/tools/list,/mcp/tools/call, etc. Entry:src/web_dashboard/mcp_http.rs - Tool consolidation: Config flag
use_consolidated_toolsreduces 50+ tools to ~15 grouped tools to save context tokens
Binaries (src/bin/)
st— Main CLI (thin client), entry point insrc/main.rsstd— Always-on daemon servicemq— Marqant markdown compression toolm8— Memory management tooln8x— Nexus Agent (tree orchestrator)import-claude-memories— Memory import utility
Key Modules
| Domain | Key Files | Purpose |
| Scanner | scanner.rs, scanner_interest.rs, scanner_safety.rs, scanner_state.rs | Filesystem traversal, interest scoring, change detection |
| Formatters | src/formatters/ | Output format handlers (classic, AI-optimized, quantum, markdown, JSON, CSV) |
| MCP | mcp.rs, src/mcp/ | Model Context Protocol integration (30+ tools, stdio/HTTP) |
| Daemon | daemon.rs, daemon_client.rs, daemon_cli.rs | HTTP API server for AI context |
| Proxy | src/proxy/ | LLM proxy with OpenAI-compatible API |
| Memory | mem8/, memory_manager.rs, mega_session_manager.rs, m8_*.rs | Wave-based memory system, session persistence |
| TUI | spicy_tui_enhanced.rs, spicy_fuzzy.rs, src/terminal/ | Interactive terminal UIs |
| Web | src/web_dashboard/ | Browser-based dashboard with real PTY |
| Security | security_scan.rs, ai_guardian.rs | Supply chain scanning, prompt injection protection |
| Smart Tools | src/smart/ | Context-aware AI tools |
| Collaboration | src/collab/ | Multi-AI collaboration features |
| Compression | compression_manager.rs, dynamic_tokenizer.rs, st_tokenizer.rs | Smart compression, tokenization |
| CLI | cli.rs | clap-based argument parsing (60+ options) |
| Config | config.rs | Configuration management |
Workspace Members
st-protocol/— Binary wire protocol (6502-inspired) for daemon-to-daemon communication onlyexpert_prompt_engineer/— Prompt engineering workspacemarqant/— Git submodule for markdown compression (excluded from workspace)
Configuration & Environment
Config files
~/.st/config.toml— Main config (API keys, model preferences, daemon settings, safety)~/.st/daemon.token— Auth token (auto-generated on first daemon run).aye_consciousness.m8— Per-directory consciousness state (persistent AI context)
Key environment variables
| Variable | Purpose | Default |
ST_TOKEN_PATH | Override auth token file location | ~/.st/daemon.token |
ST_DEFAULT_MODE | Default output format | smart |
ST_SESSION_AWARE | Enable MCP session-aware init | disabled |
MCP_DEBUG | Show MCP startup messages | disabled |
RUST_LOG | Tracing log level | info |
Systemd services
systemd/smart-tree-daemon@.service— User-level daemon (one per user)systemd/smart-tree-daemon.service— System-level daemonsystemd/smart-tree-guardian.service— System-wide protection daemon
Code Conventions
- Error handling:
anyhow::Result<T>throughout;thiserrorfor typed errors - Async:
tokioruntime with full features - HTTP:
axumframework - Git ops:
gixcrate - Serialization:
serdefor all data structures - Terminal UI:
ratatui+crossterm - Commit messages:
type: short description(types: feat, fix, docs, style, refactor, test, chore)
Feature Flags
- Default features: none (minimal build)
candle— Local LLM supportvoice— Voice featuresfull— All features enabled
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

