state-directory-manager-1-xdg-base-directory-standard
XDG Base Directory compliant state management. Use when setting up config, data, state, or cache directories per the XDG specification.
Best use case
state-directory-manager-1-xdg-base-directory-standard is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
XDG Base Directory compliant state management. Use when setting up config, data, state, or cache directories per the XDG specification.
Teams using state-directory-manager-1-xdg-base-directory-standard should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/1-xdg-base-directory-standard/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How state-directory-manager-1-xdg-base-directory-standard Compares
| Feature / Agent | state-directory-manager-1-xdg-base-directory-standard | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
XDG Base Directory compliant state management. Use when setting up config, data, state, or cache directories per the XDG specification.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 1. XDG Base Directory Standard (+2)
## 1. XDG Base Directory Standard
Follow the XDG specification for directory locations:
```bash
#!/bin/bash
# ABOUTME: XDG Base Directory compliant state management
# ABOUTME: Cross-platform directory locations
# XDG Base Directories with fallbacks
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
# Application-specific directories
APP_NAME="my-tool"
CONFIG_DIR="$XDG_CONFIG_HOME/$APP_NAME"
DATA_DIR="$XDG_DATA_HOME/$APP_NAME"
STATE_DIR="$XDG_STATE_HOME/$APP_NAME"
CACHE_DIR="$XDG_CACHE_HOME/$APP_NAME"
LOG_DIR="$STATE_DIR/logs"
# Initialize directories
init_directories() {
mkdir -p "$CONFIG_DIR"
mkdir -p "$DATA_DIR"
mkdir -p "$STATE_DIR"
mkdir -p "$CACHE_DIR"
mkdir -p "$LOG_DIR"
}
```
## 2. Workspace-Hub Pattern
Alternative using home directory (from workspace-hub scripts):
```bash
#!/bin/bash
# ABOUTME: Workspace-hub style state directory management
# ABOUTME: Simple $HOME/.app-name pattern
APP_NAME="workspace-hub"
APP_DIR="${HOME}/.${APP_NAME}"
# Directory structure
CONFIG_DIR="$APP_DIR/config"
DATA_DIR="$APP_DIR/data"
LOGS_DIR="$APP_DIR/logs"
CACHE_DIR="$APP_DIR/cache"
TEMP_DIR="$APP_DIR/tmp"
# Initialize with proper permissions
init_app_dirs() {
local dirs=("$CONFIG_DIR" "$DATA_DIR" "$LOGS_DIR" "$CACHE_DIR" "$TEMP_DIR")
for dir in "${dirs[@]}"; do
if [[ ! -d "$dir" ]]; then
mkdir -p "$dir"
chmod 700 "$dir" # Private by default
fi
done
}
# Clean old temp files
clean_temp() {
find "$TEMP_DIR" -type f -mtime +1 -delete 2>/dev/null || true
}
```
## 3. Configuration File Management
Read and write configuration files:
```bash
#!/bin/bash
# ABOUTME: Configuration file management
# ABOUTME: Key-value pairs with defaults
CONFIG_FILE="$CONFIG_DIR/config"
# Default configuration
declare -A DEFAULT_CONFIG=(
["parallel_workers"]="5"
["log_level"]="INFO"
["auto_sync"]="true"
["timeout"]="30"
)
# Initialize config with defaults
init_config() {
if [[ ! -f "$CONFIG_FILE" ]]; then
{
echo "# Configuration for $APP_NAME"
echo "# Generated: $(date)"
echo ""
for key in "${!DEFAULT_CONFIG[@]}"; do
echo "${key}=${DEFAULT_CONFIG[$key]}"
done
} > "$CONFIG_FILE"
fi
}
# Read config value
get_config() {
local key="$1"
local default="${2:-${DEFAULT_CONFIG[$key]:-}}"
if [[ -f "$CONFIG_FILE" ]]; then
local value
value=$(grep "^${key}=" "$CONFIG_FILE" 2>/dev/null | cut -d'=' -f2-)
echo "${value:-$default}"
else
echo "$default"
fi
}
# Write config value
set_config() {
local key="$1"
local value="$2"
init_config
if grep -q "^${key}=" "$CONFIG_FILE" 2>/dev/null; then
# Update existing
sed -i "s|^${key}=.*|${key}=${value}|" "$CONFIG_FILE"
else
# Add new
echo "${key}=${value}" >> "$CONFIG_FILE"
fi
}
# Load all config into associative array
load_config() {
declare -gA CONFIG
# Start with defaults
for key in "${!DEFAULT_CONFIG[@]}"; do
CONFIG[$key]="${DEFAULT_CONFIG[$key]}"
done
# Override with file values
if [[ -f "$CONFIG_FILE" ]]; then
while IFS='=' read -r key value; do
[[ "$key" =~ ^#.*$ || -z "$key" ]] && continue
CONFIG[$key]="$value"
done < "$CONFIG_FILE"
fi
}
# Usage
init_config
load_config
echo "Parallel workers: ${CONFIG[parallel_workers]}"
set_config "parallel_workers" "10"
```Related Skills
improve-codebase-architecture
Find deepening opportunities in a codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/. Use when the user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable.
wave-based-parallel-plan-execution
Orchestrate phase execution by discovering dependencies, grouping into waves, spawning subagents, and collecting results with optional wave filtering
recover-from-corrupted-git-state
Diagnose and recover from corrupted git states (stale locks, failed rebases, pre-commit hook blocks) during bulk operations
portable-config-baseline-pattern
Extract machine-agnostic settings into portable template files while keeping machine-specific hooks and plugins separate
portable-baseline-pattern-implementation
Implement portable configuration baselines by separating machine-agnostic settings from machine-specific hooks and plugins
portable-baseline-pattern-extraction
Extract and separate portable baseline config from machine-specific overrides in multi-environment projects
portable-baseline-configuration-pattern
Separate portable/universal config from machine-specific settings to enable safe template reuse across environments
portable-baseline-config-pattern
Separate machine-portable baseline config from environment-specific hooks and plugins
multi-layer-stale-state-debugging
Detect and clear stale state persisting across multiple storage layers (auth files, cache, code logic)
batch-syntax-fix-with-regex-line-based-fallback
Fix repeated syntax errors across many files using regex, then fall back to line-based parsing when regex fails
interactive-Codex-to-file-based-fallback
Switch from tmux/interactive Codex to file-based Codex -p execution when interactive runs fail with upstream errors or analysis-only stalls, then verify landing from git/GitHub state.
user-approved-plan-state-sync
Reconcile GitHub and local repo state when a plan has been user-approved, including direct approval messages that require creating the local marker and moving the issue to status:plan-approved.