state-directory-manager

Manage persistent state directories with XDG-compliant paths and cleanup for bash scripts

5 stars

Best use case

state-directory-manager is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Manage persistent state directories with XDG-compliant paths and cleanup for bash scripts

Teams using state-directory-manager 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

$curl -o ~/.claude/skills/state-directory-manager/SKILL.md --create-dirs "https://raw.githubusercontent.com/vamseeachanta/workspace-hub/main/.agents/skills/_core/bash/state-directory-manager/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/state-directory-manager/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How state-directory-manager Compares

Feature / Agentstate-directory-managerStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Manage persistent state directories with XDG-compliant paths and cleanup for bash scripts

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

# State Directory Manager

## When to Use This Skill

✅ **Use when:**
- Scripts need to persist data between runs
- Storing user preferences or configuration
- Caching results for performance
- Managing log files with rotation
- Creating portable CLI tools

❌ **Avoid when:**
- One-time scripts that don't need state
- Scripts that should be purely stateless
- When environment variables are sufficient

## Complete Example: State Manager Module

```bash
#!/bin/bash
# ABOUTME: Complete state directory manager
# ABOUTME: Reusable module for bash scripts

# ─────────────────────────────────────────────────────────────────
# State Directory Manager v1.0.0
# ─────────────────────────────────────────────────────────────────

# Application identity (override in your script)
: "${STATE_APP_NAME:=my-app}"

# Directory setup
STATE_BASE_DIR="${HOME}/.${STATE_APP_NAME}"
STATE_CONFIG_DIR="$STATE_BASE_DIR/config"
STATE_DATA_DIR="$STATE_BASE_DIR/data"
STATE_CACHE_DIR="$STATE_BASE_DIR/cache"
STATE_LOG_DIR="$STATE_BASE_DIR/logs"
STATE_TMP_DIR="$STATE_BASE_DIR/tmp"

# File paths
STATE_CONFIG_FILE="$STATE_CONFIG_DIR/config"
STATE_STATE_FILE="$STATE_DATA_DIR/state"
STATE_LOG_FILE="$STATE_LOG_DIR/app.log"


*See sub-skills for full details.*

## Usage in Scripts

```bash
#!/bin/bash
# Your script that uses the state manager

# Set app name before sourcing
STATE_APP_NAME="my-tool"

# Source the state manager
source /path/to/state-manager.sh

# Now use it
state_config_set "api_key" "abc123"
api_key=$(state_config_get "api_key")

state_set "last_run" "$(date -Iseconds)"
state_log "INFO" "Script started"

# Use cache
if ! result=$(state_cache_get "api_response"); then
    result=$(curl -s https://api.example.com/data)
    state_cache_set "api_response" "$result"
fi
```

## Resources

- [XDG Base Directory Spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
- [File Hierarchy Standard](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html)

---

## Version History

- **1.0.0** (2026-01-14): Initial release - extracted from workspace-hub patterns

## Sub-Skills

- [1. XDG Base Directory Standard (+2)](1-xdg-base-directory-standard/SKILL.md)
- [4. State File Operations](4-state-file-operations/SKILL.md)
- [5. Cache Management (+1)](5-cache-management/SKILL.md)
- [Best Practices](best-practices/SKILL.md)

Related Skills

git-sync-manager

5
from vamseeachanta/workspace-hub

Multi-repository git synchronization and fetch-pull-push patterns for batch operations across workspaces

xurl

5
from vamseeachanta/workspace-hub

X/Twitter via xurl CLI: post, search, DM, media, v2 API.

xitter

5
from vamseeachanta/workspace-hub

Interact with X/Twitter via the x-cli terminal client using official X API credentials. Use for posting, reading timelines, searching tweets, liking, retweeting, bookmarks, mentions, and user lookups.

research-paper-writing

5
from vamseeachanta/workspace-hub

End-to-end pipeline for writing ML/AI research papers — from experiment design through analysis, drafting, revision, and submission. Covers NeurIPS, ICML, ICLR, ACL, AAAI, COLM. Integrates automated experiment monitoring, statistical analysis, iterative writing, and citation verification.

cli-productivity

5
from vamseeachanta/workspace-hub

Essential CLI tools and shell productivity patterns for efficient terminal workflows

usage-tracker

5
from vamseeachanta/workspace-hub

Track and analyze usage metrics with timestamped logging, reporting, and trend detection

parallel-batch-executor

5
from vamseeachanta/workspace-hub

Parallel task execution patterns using xargs and job control for significant performance gains

json-config-loader

5
from vamseeachanta/workspace-hub

Configuration file parsing patterns for bash scripts (INI, key=value, JSON)

interactive-menu-builder

5
from vamseeachanta/workspace-hub

Build multi-level interactive CLI menus with navigation and selection for bash scripts

complexity-scorer

5
from vamseeachanta/workspace-hub

Score task complexity using keyword matching, heuristic analysis, and configurable threshold rules

bash-cli-framework

5
from vamseeachanta/workspace-hub

Universal bash CLI patterns for colors, logging, headers, and error handling

recover-from-corrupted-git-state

5
from vamseeachanta/workspace-hub

Diagnose and recover from corrupted git states (stale locks, failed rebases, pre-commit hook blocks) during bulk operations