Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1ay1 Agentty User Storage Root

From Leeroopedia
Knowledge Sources
Domains Platform, Storage
Last Updated 2026-10-28 12:00 GMT

Overview

The single per-user storage root (`~/.agentty`), with internal layout accessors and per-directory env overrides for bulk storage on a separate drive.

Description

The agentty::util::user_root module is THE single per-user storage root: `~/.agentty` (or `$AGENTTY_HOME`). agentty's per-user footprint is config + data + secrets + cache + logs, tightly coupled — the XDG base-dir spec would scatter that across four roots, and history shows a multi-root layout guarantees drift (files landed by coin-flip). One `rm -rf ~/.agentty` resets the app. One `chmod 0700` is the whole security story.

Internal layout: `settings.json`, `mcp.json`, `hooks.json`, `skills/`, `agents/`, `commands/` (user-facing config at top level); `threads/`, `memory.jsonl` (data); `credentials/` (secrets, 0700); `cache/` (refetchable); `logs/` (diagnostics). Migration from the legacy `~/.config/agentty` split-root runs once per process.

Per-directory env overrides (`$AGENTTY_THREADS_DIR`, `$AGENTTY_CACHE_DIR`, `$AGENTTY_LOGS_DIR`, `$AGENTTY_CREDENTIALS_DIR`, `$AGENTTY_STATE_DIR`) let users keep config on the system disk while bulk data goes to a second drive — the default is still ONE root, and an override changes nothing for anyone who doesn't set it.

Usage

Import this when you need to: resolve the user storage root or any subdirectory (credentials, threads, cache, logs, state).

Code Reference

Source Location

Signature

namespace agentty::util {

// The per-user root (~/.agentty or $AGENTTY_HOME). Created 0700 on first use.
[[nodiscard]] std::filesystem::path user_root();

// Subdirectory accessors — each creates its dir on first use:
[[nodiscard]] std::filesystem::path user_credentials_dir();  // secrets, 0700
[[nodiscard]] std::filesystem::path user_state_dir();        // approvals
[[nodiscard]] std::filesystem::path user_cache_dir();        // refetchable
[[nodiscard]] std::filesystem::path user_logs_dir();         // diagnostics
[[nodiscard]] std::filesystem::path user_threads_dir();      // conversation history
}

Import

#include "agentty/util/user_root.hpp"

I/O Contract

Inputs

Name Type Required Description
$AGENTTY_HOME env var No Overrides the root wholesale
$AGENTTY_THREADS_DIR env var No Overrides threads directory
$AGENTTY_CACHE_DIR env var No Overrides cache directory
$AGENTTY_LOGS_DIR env var No Overrides logs directory
$AGENTTY_CREDENTIALS_DIR env var No Overrides credentials directory

Outputs

Name Type Description
user_root() fs::path ~/.agentty (or $AGENTTY_HOME), created 0700
user_credentials_dir() fs::path ~/.agentty/credentials, 0700
user_threads_dir() fs::path ~/.agentty/threads

Usage Examples

Resolve Paths

#include "agentty/util/user_root.hpp"

auto root = agentty::util::user_root();              // ~/.agentty
auto creds = agentty::util::user_credentials_dir();  // ~/.agentty/credentials (0700)
auto log_file = agentty::util::user_logs_dir() / "agentty.log";
auto threads = agentty::util::user_threads_dir();    // ~/.agentty/threads

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment