agentleFS
sefaertuncsefaertunc/Worclaude/.claude/skills/project-patterns/SKILL.md

project-patterns

Skill4 starsChanged 7 months agoMITView on GitHub

Architectural patterns, naming conventions, file organization, and error handling for the worclaude CLI project

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 8 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All user-facing output goes through display.*:

    line 71
  2. Very specific:

    Never use console.log for user output.

    line 78
  3. Distinctive:

    Always operate on parsed objects, never on stringified JSON:

    line 81
  4. Distinctive:

    Don't simplify to a single pass.

    line 99
  5. Distinctive:

    Tier 1 (additive): only when target file doesn't exist at all

    line 102
  6. Distinctive:

    Tier 3 (interactive): only for CLAUDE.md and hook matcher conflicts

    line 104
  7. Very specific:

    Create template in templates/agents/optional/{category}/

    line 107
  8. Very specific:

    Add to AGENT_CATALOG in src/data/agents.js

    line 108
  9. Very specific:

    Add routing metadata in src/data/agent-registry.js

    line 109
  10. Distinctive:

    Add to scaffolder file list for hash computation

    line 110
  11. Distinctive:

    Test Scenario A (fresh) and Scenario B (existing with conflicts)

    line 112
  12. Distinctive:

    No central error handler. Try/catch at the command level:

    line 116
  13. Distinctive:

    No retry logic anywhere. No circuit breakers.

    line 134

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Project Patterns

Architecture Overview

Single-process Node.js CLI tool. No server, no database, no external service dependencies (except npm registry for version checks with 5s timeout). Pure filesystem operations — reads templates, writes scaffolded files, merges with existing user files.

Layer diagram:

CLI Entry (index.js)
  └── Commands (commands/*.js) — orchestration, user flow
        ├── Prompts (prompts/*.js) — Inquirer interactions, isolated from logic
        ├── Core (core/*.js) — business logic, no user interaction*
        ├── Generators (generators/*.js) — produce file content dynamically
        ├── Data (data/*.js) — constants, catalogs, registries
        └── Utils (utils/*.js) — pure helpers, no side effects

*Exception: merger.js calls promptHookConflict() directly — pragmatic compromise.

Key invariant: Commands orchestrate between prompts and core. Prompts never call core directly. Core never prompts the user (except merger.js).

Naming Conventions

  • Files: kebab-case everywhere, no exceptions (agent-routing.js, file-categorizer.js, claude-md-merge.js)
  • Test files: mirror source name + .test.js suffix (merger.test.js, agent-routing-integration.test.js)
  • Functions: camelCase (buildSettingsJson, mergeSettingsPermissionsAndHooks)
  • Constants: UPPER_SNAKE_CASE (UNIVERSAL_AGENTS, AGENT_CATALOG)
  • No private prefix: unexported functions are private by convention — no underscore prefix

File Organization

Layer-based (not feature-based):

src/
├── index.js              # CLI entry point (Commander.js setup)
├── commands/             # One file per CLI command (init, upgrade, status, backup, restore, diff)
├── core/                 # Business logic: scaffolder, merger, detector, backup, config, file-categorizer
├── prompts/              # Inquirer prompt definitions: project-type, tech-stack, agent-selection, conflicts
├── generators/           # Dynamic content builders (agent-routing.js)
├── data/                 # Constants: agents.js (catalogs), agent-registry.js (routing metadata)
└── utils/                # Pure helpers: display.js, file.js, hash.js, time.js, npm.js

templates/                # User-facing template files (quality matters — these ship to users)
├── settings/             # 16 language-specific + base + docker JSON templates
├── agents/               # universal/ (5) + optional/ (18 across 6 categories)
├── commands/             # 10 slash command templates
└── skills/               # universal/ (9) + templates/ (3 placeholder skills)

tests/
├── commands/             # Tests mirror src/ structure
├── core/
├── prompts/
├── utils/
└── fixtures/             # Test projects: fresh-project, existing-project, workflow-project

Where new things go:

  • New CLI command → src/commands/ + register in src/index.js
  • New agent → template in templates/agents/ + entry in agents.js + entry in agent-registry.js
  • New skill → template in templates/skills/ + scaffolder reference + hash computation
  • New utility → src/utils/ (must be pure, no side effects)

Common Patterns

Display namespace pattern

All user-facing output goes through display.*:

import * as display from '../utils/display.js';
display.success('Done!');
display.error('Something failed');
display.newline();

Never use console.log for user output.

JSON manipulation pattern

Always operate on parsed objects, never on stringified JSON:

// CORRECT
const settings = JSON.parse(templateContent);
settings.permissions.allow.push(...newPermissions);
const output = JSON.stringify(settings, null, 2);

// WRONG — will break on special characters
const output = templateString.replace('{{permissions}}', newPermissions);

Two-pass JSON parsing (parseUserJson)

User JSON files may have shell-escaped braces from zsh heredoc artifacts:

// Pass 1: try raw JSON.parse
// Pass 2: strip \{ → { and \} → }, then JSON.parse
// Both fail: throw with clear error message

Don't simplify to a single pass.

Tiered merge hierarchy

  • Tier 1 (additive): only when target file doesn't exist at all
  • Tier 2 (reference copy): always saves the template under .claude/workflow-ref/<path> when same-name file exists (even if content is identical). Preserves the original filename so diff against the live file is trivial. Kept out of .claude/commands/ and .claude/agents/ to avoid being discovered as a phantom command or agent.
  • Tier 3 (interactive): only for CLAUDE.md and hook matcher conflicts

Adding a new agent end-to-end

  1. Create template in templates/agents/optional/{category}/
  2. Add to AGENT_CATALOG in src/data/agents.js
  3. Add routing metadata in src/data/agent-registry.js
  4. Add to scaffolder file list for hash computation
  5. Write tests
  6. Test Scenario A (fresh) and Scenario B (existing with conflicts)

Error Handling Philosophy

No central error handler. Try/catch at the command level:

// Pattern in every command file
try {
  // ... main work
} catch (err) {
  spinner?.fail('Human-readable failure message');
  display.error(err.message);
  process.exit(1);
}
  • Operational errors (malformed JSON, missing files): throw with clear message from the detecting function, bubble up to command-level catch
  • User errors (invalid input): handled inline by Inquirer validation, never throw
  • Network errors (npm registry): caught with timeout, graceful degradation (skip version check)
  • Permission errors (EACCES on npm install): caught specifically, suggest sudo

No retry logic anywhere. No circuit breakers. Operations are local and idempotent — if something fails, the user re-runs the command.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.