state-directory-manager-4-state-file-operations
について
このスキルは、スクリプト実行間で永続的なデータを追跡するための状態ファイル操作を提供します。実行履歴、進捗状況、ステータスを追跡するためのJSON状態ファイルを初期化、読み取り、更新する機能を含みます。Claude Codeスクリプトの複数回の実行にわたって状態を維持する必要がある場合にご利用ください。
クイックインストール
Claude Code
推奨npx skills add vamseeachanta/workspace-hub/plugin add https://github.com/vamseeachanta/workspace-hubgit clone https://github.com/vamseeachanta/workspace-hub.git ~/.claude/skills/state-directory-manager-4-state-file-operationsこのコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします
ドキュメント
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
}
GitHub リポジトリ
関連スキル
algorithmic-art
メタ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.
subagent-driven-development
開発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.
executing-plans
デザイン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.
cost-optimization
その他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.
