Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
duc01226 avatar

Code Patterns

  • 17 installs
  • 7 repo stars
  • Updated June 18, 2026
  • duc01226/easyplatform

Applies implementation patterns for file I/O safety, atomic writes, persistence, and validation in concurrent, file-based code.

About

Provides code implementation patterns and best practices learned from real mistakes, covering file I/O safety, persistence, and validation. A developer uses it when building file-based state, shared resources, or concurrent-access code.

  • Covers file I/O safety: locking, atomic writes, data persistence
  • Documents validation patterns for shared resources and concurrent access

Code Patterns by the numbers

  • 17 all-time installs (skills.sh)
  • Ranked #3,475 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Jul 29, 2026 (Skillselion catalog sync)
npx skills add https://github.com/duc01226/easyplatform --skill code-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs17
repo stars7
Last updatedJune 18, 2026
Repositoryduc01226/easyplatform

What it does

Applies implementation patterns for file I/O safety, atomic writes, persistence, and validation in concurrent, file-based code.

Files

SKILL.mdMarkdownGitHub ↗

Code Patterns

Best practices distilled from implementation lessons. These patterns prevent common bugs in file I/O, data persistence, and validation.

Core Principle

LEARN FROM MISTAKES - DON'T REPEAT THEM

Each pattern here was extracted from a real bug or issue. Apply these patterns proactively to prevent the same mistakes.

When to Use

Always use for: File-based state, shared resources, data persistence, validation layers, concurrent access

Especially when: Multiple processes/hooks access same file, persisting JSON data, creating factory functions, implementing save/load logic

The Patterns

1. File Locking (references/file-io.md)

Advisory file locking for shared state access.

Problem: Multiple processes writing to same file causes data corruption or race conditions.

Solution: Use .lock file pattern with timeout and stale lock detection.

⚠️ MUST READ when: Implementing file-based state accessed by multiple hooks/processes

2. Atomic Writes (references/data-persistence.md)

Safe file persistence that survives crashes.

Problem: writeFileSync() mid-write crash corrupts file.

Solution: Write to .tmp, rename to final path (atomic on POSIX), handle Windows with backup pattern.

⚠️ MUST READ when: Persisting any JSON/data file that must survive unexpected termination

3. Schema Validation (references/data-validation.md)

Validate before every persist operation.

Problem: Factory functions create invalid data that persists and causes downstream issues.

Solution: Validate at creation AND before every write. Never trust "it was validated earlier."

⚠️ MUST READ when: Creating factory functions, implementing create/update operations, building data pipelines

Quick Reference

Shared file access → file-io.md (add locking)
JSON persistence → data-persistence.md (atomic writes)
Factory function → data-validation.md (validate output)

Prevention Checklist

Before implementing file I/O:

  • [ ] Will multiple processes access this file?
  • [ ] What happens if write crashes mid-operation?
  • [ ] Is data validated before every write?
  • [ ] Are stale locks handled (dead process detection)?

Origin

These patterns were extracted from hook infrastructure implementation review:

  • Race condition in concurrent file writes → file-io.md
  • File corruption risk on crash → data-persistence.md
  • Invalid data persisting without validation → data-validation.md

IMPORTANT Task Planning Notes

  • Always plan and break many small todo tasks
  • Always add a final review todo task to review the works done at the end to find any fix or enhancement needed

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.