Use when implementing language-agnostic patterns like layered architecture, dependency injection, error handling, or code organization principles across any technology stack.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Use when implementing language-agnostic patterns like layered architecture, dependency injection, error handling, or code organization principles across any technology stack.
user-invocable
false
Universal Development Patterns
Overview
Language-agnostic development patterns and best practices applicable across all technology stacks.
The deep catalog lives next door — read it for any real design decision
This file is the quick reference. It carries enough to keep everyday code honest. It is
deliberately shallow on architecture, and it contains none of the 22 GoF design
patterns.
For anything beyond a reminder — choosing a style, comparing two, or picking a design
pattern — read the architecture skill's index, then follow where it routes you:
<dev-plugin-root>/skills/architecture/SKILL.md
Locate it relative to this plugin's root, which covers both the installed-cache and
local-source layouts:
That index routes in two steps: altitude first (is this about system shape or class
collaboration), then the specific file. What it covers, none of which is below:
all 22, with TypeScript, trade-offs, and when not to use each
Selection
references/selection.md
how to choose, overuse smells, and where TypeScript already gives you the pattern free
Do not answer an architecture question from the summaries below when the deep file
exists. The summaries omit the trade-offs and the failure modes, which are the parts that
decide whether the choice is right.
Architecture Patterns (summary — see the architecture skill for the real treatment)
// BAD: Multiple responsibilities
function processUser(user) {
validateUser(user);
saveToDatabase(user);
sendEmail(user);
logAnalytics(user);
}
// GOOD: Single responsibility
function validateUser(user) { /* validation only */ }
function saveUser(user) { /* persistence only */ }
function notifyUser(user) { /* notification only */ }
Dependency Injection
Inject dependencies rather than creating them internally.
// BAD: Hard dependency
class UserService {
constructor() {
this.db = new Database(); // Hard-coded
}
}
// GOOD: Injected dependency
class UserService {
constructor(db) {
this.db = db; // Injected
}
}
Interface Segregation
Prefer many specific interfaces over one general interface.
Validate inputs early and fail immediately on invalid data.
function processOrder(order) {
// Validate early
if (!order) throw new Error('Order required');
if (!order.items?.length) throw new Error('Order must have items');
if (!order.customerId) throw new Error('Customer ID required');
// Process only after validation passes
return executeOrder(order);
}
Error Boundaries
Contain errors at appropriate boundaries.
// API boundary - catch and format errors
async function apiHandler(req, res) {
try {
const result = await processRequest(req);
res.json({ success: true, data: result });
} catch (error) {
res.status(error.statusCode || 500).json({
success: false,
error: error.message
});
}
}
Result Types (Where Supported)
Use Result/Either types instead of exceptions for expected failures.
Using strings where enums/types would be safer. Use type systems.
Copy-Paste Programming
Duplicating code instead of abstracting. But: prefer duplication over wrong abstraction.
Boolean Parameters
Functions with boolean flags that change behavior. Split into explicit functions.
// BAD
function process(data, isAdmin) { /* behaves differently based on flag */ }
// GOOD
function processUserData(data) { /* user logic */ }
function processAdminData(data) { /* admin logic */ }
Performance Principles
Measure First: Profile before optimizing
Lazy Loading: Load resources only when needed
Caching: Cache expensive computations and API calls
Pagination: Don't load everything at once
Batch Operations: Combine multiple operations when possible
Async/Parallel: Use concurrency for independent operations
Security Principles
Input Validation: Never trust user input
Output Encoding: Encode data for its context (HTML, SQL, etc.)
Least Privilege: Request minimum permissions needed
Defense in Depth: Multiple layers of security
Fail Secure: Default to denying access on errors
Secrets Management: Never hardcode secrets, use environment variables
Language-Specific Knowledge Bases (cross-plugin)
These universal patterns are language-agnostic. When the task targets a specific
language, a companion plugin may ship a curated, production-grade knowledge base
for it. Prefer that knowledge over generic patterns when it exists.
Go — the go plugin's knowledge base
If the task involves Go, check whether the go@magus plugin is installed alongside
this one and read its knowledge base. It is bundled as plain files next to the dev
plugin, so locate it relative to this plugin's root (${CLAUDE_PLUGIN_ROOT}), which
covers both install topologies:
# Both layouts: installed cache (…/cache/magus/go/<version>/) and local source# (…/plugins/go/). Run from inside an agent that knows ${CLAUDE_PLUGIN_ROOT}:ls"${CLAUDE_PLUGIN_ROOT}/../go/knowledge/roles" 2>/dev/null \
|| ls"${CLAUDE_PLUGIN_ROOT}"/../../go/*/knowledge/roles 2>/dev/null
If found, read the files matching your role and task before writing Go:
knowledge/roles/<role>/best-practices.md — role guidance (developer,
architect, tester, code-reviewer)
knowledge/roles/<role>/implementation-references.md — index into the references
knowledge/uber-go-style-guide.md, knowledge/100-go-mistakes.md,
knowledge/go-proverbs.md — style and pitfalls
Apply this Go knowledge in preference to the generic patterns above. The role names
map to dev agents: developer→dev:developer, architect→dev:architect,
tester→dev:test-architect, code-reviewer→dev:reviewer.
If NOT found and the task is Go-heavy, tell the user once, then proceed with the
generic patterns:
💡 A curated Go knowledge base (Uber style guide, 100 Go Mistakes, production
patterns) is available in the go plugin. Install it for higher-quality Go work:
/plugin install go@magus
Do not block on this — it is an enhancement, not a requirement.
Universal patterns applicable to all technology stacks