MCP HubMCP Hub
Retour aux compétences

state-directory-manager-4-state-file-operations

vamseeachanta
Mis à jour Today
9 vues
3
2
3
Voir sur GitHub
Autregeneral

À propos

Cette compétence fournit des opérations sur les fichiers d'état pour suivre des données persistantes entre les exécutions de scripts. Elle inclut des fonctions pour initialiser, lire et mettre à jour des fichiers d'état JSON afin de suivre l'historique des exécutions, la progression et le statut. Utilisez-la lorsque vous avez besoin de maintenir un état à travers plusieurs exécutions de vos scripts Claude Code.

Installation rapide

Claude Code

Recommandé
Principal
npx skills add vamseeachanta/workspace-hub
Commande PluginAlternatif
/plugin add https://github.com/vamseeachanta/workspace-hub
Git CloneAlternatif
git clone https://github.com/vamseeachanta/workspace-hub.git ~/.claude/skills/state-directory-manager-4-state-file-operations

Copiez et collez cette commande dans Claude Code pour installer cette compétence

Documentation

4. State File Operations

4. State File Operations

Track persistent state between runs:

#!/bin/bash
# ABOUTME: State file operations
# ABOUTME: Track last run, progress, etc.

STATE_FILE="$STATE_DIR/state.json"

# Initialize state
init_state() {
    if [[ ! -f "$STATE_FILE" ]]; then
        cat > "$STATE_FILE" << EOF
{
    "version": "1.0.0",
    "created": "$(date -Iseconds)",
    "last_run": null,
    "run_count": 0,
    "last_status": null
}
EOF
    fi
}

# Get state value (requires jq)
get_state() {
    local key="$1"
    local default="${2:-null}"

    if [[ -f "$STATE_FILE" ]] && command -v jq &>/dev/null; then
        jq -r ".$key // $default" "$STATE_FILE"
    else
        echo "$default"
    fi
}

# Update state value (requires jq)
set_state() {
    local key="$1"
    local value="$2"

    init_state

    if command -v jq &>/dev/null; then
        local temp=$(mktemp)
        jq ".$key = $value" "$STATE_FILE" > "$temp" && mv "$temp" "$STATE_FILE"
    fi
}

# Record run
record_run() {
    local status="$1"

    set_state "last_run" "\"$(date -Iseconds)\""
    set_state "last_status" "\"$status\""
    set_state "run_count" "$(($(get_state run_count 0) + 1))"
}

# Simple key-value state (no jq required)
STATE_KV_FILE="$STATE_DIR/state.kv"

get_state_kv() {
    local key="$1"
    local default="$2"

    if [[ -f "$STATE_KV_FILE" ]]; then
        grep "^${key}=" "$STATE_KV_FILE" 2>/dev/null | cut -d'=' -f2- || echo "$default"
    else
        echo "$default"
    fi
}

set_state_kv() {
    local key="$1"
    local value="$2"

    mkdir -p "$(dirname "$STATE_KV_FILE")"

    if [[ -f "$STATE_KV_FILE" ]] && grep -q "^${key}=" "$STATE_KV_FILE"; then
        sed -i "s|^${key}=.*|${key}=${value}|" "$STATE_KV_FILE"
    else
        echo "${key}=${value}" >> "$STATE_KV_FILE"
    fi
}

Dépôt GitHub

vamseeachanta/workspace-hub
Chemin: .claude/skills/_core/bash/state-directory-manager/4-state-file-operations

Compétences associées

algorithmic-art

Méta

This Claude Skill creates original algorithmic art using p5.js with seeded randomness and interactive parameters. It generates .md files for algorithmic philosophies, plus .html and .js files for interactive generative art implementations. Use it when developers need to create flow fields, particle systems, or other computational art while avoiding copyright issues.

Voir la compétence

subagent-driven-development

Développement

This skill executes implementation plans by dispatching a fresh subagent for each independent task, with code review between tasks. It enables fast iteration while maintaining quality gates through this review process. Use it when working on mostly independent tasks within the same session to ensure continuous progress with built-in quality checks.

Voir la compétence

executing-plans

Design

Use the executing-plans skill when you have a complete implementation plan to execute in controlled batches with review checkpoints. It loads and critically reviews the plan, then executes tasks in small batches (default 3 tasks) while reporting progress between each batch for architect review. This ensures systematic implementation with built-in quality control checkpoints.

Voir la compétence

cost-optimization

Autre

This Claude Skill helps developers optimize cloud costs through resource rightsizing, tagging strategies, and spending analysis. It provides a framework for reducing cloud expenses and implementing cost governance across AWS, Azure, and GCP. Use it when you need to analyze infrastructure costs, right-size resources, or meet budget constraints.

Voir la compétence