config-state-patterns

Design atomic config and state persistence with defaults merging and lock-based access.

10|11|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/microsoft/amplifier-bundle-skills --skill config-state-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: config-state-patterns
Source: https://github.com/microsoft/amplifier-bundle-skills/tree/main/skills/config-state-patterns
Command: npx skills add https://github.com/microsoft/amplifier-bundle-skills --skill config-state-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you build tools that store user settings and runtime state reliably without corrupting files, losing defaults, or mixing configuration with secrets.

Core Features & Use Cases

  • Defaults Merge for Config: Loads settings by combining saved values with current defaults so older or incomplete files still work.
  • Safe State Persistence: Writes state atomically so crashes or concurrent access do not leave partial files behind.
  • Concurrency Guardrails: Uses locks to coordinate reads and writes in async or threaded programs.
  • Conventional Storage Layout: Organizes config, state, and secrets into predictable XDG-style paths.
  • Use Case: A CLI service can keep host and port settings in one file, session state in another, and auth tokens in a protected secret file.

Quick Start

Ask for a config-and-state storage pattern that separates defaults, atomic writes, locks, and XDG paths for your tool.

Frequently Asked Questions about config-state-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent file corruption during concurrent configuration writes?

Prevent configuration file corruption during concurrent writes by applying lock-based access patterns and atomic file replacement, ensuring incomplete data is never persisted even if a crash occurs mid-write.

What is the best way to merge saved configuration files with new default values?

Merge configuration files with new defaults using a known-keys-only filtering approach, combining saved values with current defaults so older or incomplete files still work without losing existing settings.

How do I organize config, state, and secrets files using XDG paths?

Organize config, state, and secrets using conventional XDG-style storage layouts, placing host settings, session state, and auth tokens into predictable, separated, and protected file paths.

Does atomic file replacement work for async or threaded state persistence?

Atomic file replacement works for async or threaded state persistence by coordinating reads and writes with concurrency guardrails and locks, preventing race conditions and configuration drift.

Why does my application lose settings when the configuration file format changes?

Your application loses settings during configuration file changes because it lacks defaults merging and known-keys-only filtering, which prevents configuration drift by safely preserving valid older values.