claude-code-ultimate-guide/examples/scripts
Florian BRUNIAUX 0630fcd883 feat: add configuration management and MCP secrets workflows (closes #16204)
Major additions to address critical gaps in Claude Code configuration:

## New Documentation Sections

1. Section 3.2.1 "Version Control & Backup" (guide/ultimate-guide.md:4085)
   - Configuration hierarchy: global → project → local
   - Git strategy for ~/.claude (symlinks approach)
   - Backup strategies: Git remote, cloud sync, cron
   - Multi-machine sync workflows
   - Disaster recovery procedures
   - Documented .claude/settings.local.json (previously undocumented)

2. Section 8.3.1 "MCP Secrets Management" (guide/ultimate-guide.md:8113)
   - Three practical approaches: OS Keychain, .env, Secret Vaults
   - Secrets rotation workflow
   - Pre-commit secret detection
   - Verification checklist
   - Best practices summary

## New Templates

1. sync-claude-config.sh (examples/scripts/)
   - Commands: setup, sync, backup, restore, validate
   - .env parsing + envsubst for variable substitution
   - Git repo creation with symlinks
   - Validation checks (secrets not in Git)

2. pre-commit-secrets.sh (examples/hooks/bash/)
   - Detects 10+ secret patterns (OpenAI, GitHub, AWS, etc.)
   - Whitelist system for false positives
   - Clear error messages with remediation steps

3. settings.local.json.example (examples/config/)
   - Machine-specific overrides template
   - Example use cases and patterns

## Resource Evaluation

- Added docs/resource-evaluations/ratinaud-config-management-evaluation.md
- Score: 5/5 (CRITICAL)
- Validated via 3 Perplexity searches + technical-writer agent challenge
- Community demand: GitHub #16204 + brianlovin/claude-config

## Updated References

- machine-readable/reference.yaml: 22 new entries
- Configuration management sections
- MCP secrets workflows
- Community resources (Ratinaud, brianlovin, GitHub issue)

## Impact

- Security: Pre-commit hook prevents secret leaks
- Productivity: Multi-machine sync reduces manual reconfig
- Team coordination: Onboarding workflow for ~/.claude setup
- Disaster recovery: Backup/restore strategies documented

Credits:
- Martin Ratinaud (504 sessions, LinkedIn post)
- brianlovin/claude-config (community example)
- GitHub Issue #16204 (community request)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-02 18:17:42 +01:00
..
audit-scan.sh fix(docs): critical factual corrections v3.6.1 2026-01-15 09:16:53 +01:00
bridge-plan-schema.json feat: add bridge script for Claude Code → LM Studio execution (v3.12.1) 2026-01-25 18:43:05 +01:00
bridge.py feat: add bridge script for Claude Code → LM Studio execution (v3.12.1) 2026-01-25 18:43:05 +01:00
check-claude.ps1 chore: release v2.5.0 with content optimization and script externalization 2026-01-11 13:52:19 +01:00
check-claude.sh feat(docs): add comprehensive data privacy documentation v3.2.0 2026-01-14 20:42:19 +01:00
clean-reinstall-claude.ps1 chore: release v2.5.0 with content optimization and script externalization 2026-01-11 13:52:19 +01:00
clean-reinstall-claude.sh chore: release v2.5.0 with content optimization and script externalization 2026-01-11 13:52:19 +01:00
fresh-context-loop.sh fix(sync): update landing sync script for new directory structure 2026-01-17 15:42:03 +01:00
migrate-arguments-syntax.ps1 docs: update $ARGUMENTS syntax for v2.1.19 breaking change + evaluation 2026-01-26 17:37:49 +01:00
migrate-arguments-syntax.sh docs: update $ARGUMENTS syntax for v2.1.19 breaking change + evaluation 2026-01-26 17:37:49 +01:00
README.md feat: add bridge script for Claude Code → LM Studio execution (v3.12.1) 2026-01-25 18:43:05 +01:00
rtk-benchmark.sh docs: enrich RTK evaluation with T3 Stack production testing 2026-01-28 14:01:37 +01:00
session-search.sh feat(scripts): session-search v2.1 - JSON encoding fix and clean previews 2026-01-15 10:20:52 +01:00
session-stats.sh feat(docs): add LLM Handbook + Google Whitepaper integration v3.3.0 2026-01-14 21:00:49 +01:00
sync-claude-config.sh feat: add configuration management and MCP secrets workflows (closes #16204) 2026-02-02 18:17:42 +01:00

Scripts

Utility scripts for Claude Code power users.

Overview

Script Description
audit-scan.sh Security and quality audit of Claude Code setup
check-claude.sh/.ps1 Health check for Claude Code installation
clean-reinstall-claude.sh/.ps1 Clean reinstall of Claude Code
fresh-context-loop.sh Run Claude Code in fresh context loops
session-search.sh Search across Claude Code session histories
session-stats.sh Statistics about Claude Code sessions
bridge.py Bridge: Claude Code → doobidoo → LM Studio

Bridge Script (Claude Code → LM Studio)

Purpose: Execute Claude Code plans locally via LM Studio for cost savings.

Architecture

┌──────────────┐     store_memory      ┌─────────────────┐
│ Claude Code  │ ─────────────────────►│    doobidoo     │
│   (Opus)     │   tag: "plan"         │   SQLite + Vec  │
│   PLANNER    │   status: "pending"   │ ~/.mcp-memory-  │
└──────────────┘                       │  service/       │
                                       └────────┬────────┘
                                                │
                                                │ Direct SQLite read
                                                ▼
                                       ┌─────────────────┐
                                       │   bridge.py     │
                                       │                 │
                                       │ • PlanReader    │
                                       │ • StepExecutor  │
                                       │ • Validator     │
                                       └────────┬────────┘
                                                │
                                                │ HTTP POST
                                                │ /v1/chat/completions
                                                ▼
                                       ┌─────────────────┐
                                       │    LM Studio    │
                                       │  localhost:1234 │
                                       └─────────────────┘

Requirements

pip install httpx
  • doobidoo MCP server with SQLite backend (~/.mcp-memory-service/)
  • LM Studio running on localhost:1234 with a loaded model

Usage

# Check LM Studio is running
python bridge.py --health

# List pending plans
python bridge.py --list

# Execute all pending plans
python bridge.py

# Execute specific plan
python bridge.py --plan plan_auth_refactor

# Verbose mode
python bridge.py -v

Workflow

1. Claude Code creates the plan

In Claude Code (Opus), store a plan via doobidoo:

store_memory("""
{
  "$schema": "bridge-plan-v1",
  "id": "plan_auth_refactor",
  "status": "pending",
  "context": {
    "project": "/path/to/project",
    "objective": "Refactor authentication to use JWT",
    "files_context": {
      "src/auth.py": "LOAD",
      "src/config.py": "REFERENCE"
    }
  },
  "steps": [
    {
      "id": 1,
      "type": "analysis",
      "description": "Analyze current auth implementation",
      "prompt": "Analyze the authentication code and identify migration points for JWT.",
      "validation": {"type": "non_empty"}
    },
    {
      "id": 2,
      "type": "code_generation",
      "description": "Generate JWT middleware",
      "prompt": "Generate a JWT authentication middleware based on the analysis.",
      "depends_on": [1],
      "validation": {"type": "syntax_check"},
      "file_output": "src/jwt_auth.py"
    }
  ]
}
""", tags=["plan"])

2. Execute via bridge

python bridge.py
# Reads plan from doobidoo SQLite
# Executes each step via LM Studio
# Stores results back in doobidoo

3. Retrieve results in Claude Code

search_by_tag(["result", "plan_auth_refactor"])
# Returns all execution results

Plan Schema

See bridge-plan-schema.json for the complete JSON Schema.

Field Required Description
$schema Yes Must be "bridge-plan-v1"
id Yes Unique plan ID (e.g., plan_auth_refactor)
status Yes pending, in_progress, completed, failed
context.objective Yes High-level goal description
context.project No Absolute path to project root
context.files_context No Files to inject (LOAD) or reference
steps Yes Array of execution steps

Step Types

Type Use Case
analysis Analyze code, identify patterns, plan changes
code_generation Generate new code from scratch
code_modification Modify existing code
decision Make architectural or design decisions

Validation Types

Type Description
non_empty Output is not empty (default)
json Valid JSON output
syntax_check Valid Python syntax
contains_keys JSON contains specific keys

Failure Handling

on_failure Behavior
retry_with_context Retry with error feedback (default)
skip Skip step, continue execution
halt Stop entire plan

Cost Savings

  • Planning (Opus): ~$0.50-2.00 per complex plan
  • Execution (LM Studio): Free (local)
  • ROI: 80-90% cost reduction on implementation tasks

Limitations

Limitation Mitigation
Local model quality varies Strict validation + retries
No MCP tools in LM Studio Inject file content in context
Limited context window Truncate old results
No streaming 120s timeout per step

Audit Scan

Security and quality audit of your Claude Code configuration.

./audit-scan.sh

Checks:

  • Sensitive data in CLAUDE.md files
  • Permission configurations
  • MCP server security
  • Hook script safety

Health Check

Quick verification of Claude Code installation.

# macOS/Linux
./check-claude.sh

# Windows
./check-claude.ps1

Clean Reinstall

Complete reinstall preserving configurations.

# macOS/Linux
./clean-reinstall-claude.sh

# Windows
./clean-reinstall-claude.ps1

Fresh Context Loop

Run Claude Code with fresh context for long-running tasks.

./fresh-context-loop.sh --iterations 5 --project /path/to/project

Search across all Claude Code session histories.

./session-search.sh "authentication"

Session Stats

Get statistics about your Claude Code usage.

./session-stats.sh