Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Code Structure

ASecurity

Separate orchestration from reusable mechanics while preserving transactions. Use when workflows duplicate operational logic.

2 stars
0 votes
0 copies
0 views
Added 9/23/2026
ai-agentsgotestingrefactoringapidatabase

Works with

api

Security Analysis

A100/100

Scanned 9/23/2026

Install to Claude Code

$npx -y skills add jaydubya818/MissionControl --skill code-structure --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Structure?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Code Structure
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jaydubya818-code-structure/badge)](https://www.skillsdirectory.com/skills/jaydubya818-code-structure)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: code-structure
description: Separate orchestration from reusable mechanics while preserving transactions. Use when workflows duplicate operational logic.
metadata:
  author: michaelshimeles
  version: "2.0.0"
  owner: software-factory
  risk: low
  capabilities: architecture,refactoring
---

# Service Layer Architecture

## Overview

This collection prefers a two-layer separation: actions orchestrate domain
rules, while services implement reusable operations. Use it where the project
has no established convention. Preserve existing domain services, repositories,
transaction boundaries, and framework patterns when they already fit the task.

This prevents duplicated code, inconsistent behavior, and bugs fixed in one path but not others.

## When to Use

- Multiple callers need the same low-level operation (sandbox creation, email sending, payment processing)
- You're copy-pasting operational logic between action files
- A bug fix in one workflow doesn't propagate to others doing the same thing
- Adding a new feature that shares mechanics with existing flows

Avoid extraction that adds indirection without a concrete benefit. Repetition
is a useful signal, but a single caller can justify a boundary for testing,
provider isolation, transactions, or complex logic.

## Core Pattern

```
Orchestration Layer (Actions)          Service Layer (Shared Mechanics)
├── owns business rules                ├── owns reusable operations
├── owns state transitions             ├── owns provider/SDK interactions
├── owns auth/ownership checks         ├── owns command execution details
├── owns failure classification        ├── owns health checks / readiness
├── owns retries / user-facing errors  └── returns structured results
└── calls service functions
```

**Rule of thumb:**
- "What this product flow means" → keep in actions
- "How to do this operation reliably" → move to service layer

## Quick Reference

| Design Principle | Do | Don't |
|---|---|---|
| API shape | Composable capability blocks | One giant "do everything" method |
| Inputs/outputs | Explicit dependencies and meaningful results | Hidden global state or undocumented side effects |
| Migration | Extract one block, replace one caller, verify, then migrate rest | Refactor everything at once |
| Domain logic | Put policy and transactions in the project's established owner | Scatter the same policy across callers |
| Extraction trigger | Repeated mechanics or a concrete boundary benefit | Speculative abstractions with no current benefit |

## Designing Service Functions

Design as **capability blocks**, not monoliths:

```ts
// Good: composable, each caller chooses what to use
createManagedSandbox(...)
prepareRepo(...)
detectPackageManager(...)
installDependencies(...)
runBuildCommand(...)
startSandboxRuntime(...)
```

Each function should:
- Accept all required data as **explicit parameters**
- Return **structured outputs** (e.g., `{ ready, previewUrl, proxyPort }`)
- Inject database or repository access when the service owns persistence under
  the project's architecture. State writes and transaction boundaries explicitly.
- Make failure explicit through typed results or documented exceptions

This lets callers choose strict vs relaxed behavior per flow.

## Migration Checklist

When extracting shared logic:

1. Identify the existing owners of policy, persistence, and transactions
2. Mark repeated operations or boundaries with a concrete current benefit
3. Extract a cohesive operation consistent with those owners
4. Replace one caller → verify → replace remaining callers
5. Preserve auth, status transitions, error handling, and transaction behavior
6. Run verification: typecheck, lint, confirm all flows still work

## Anti-Patterns

| Anti-Pattern | Problem |
|---|---|
| **God service** | One huge function hides all control flow |
| **Leaky service** | Hidden state changes or unclear transaction ownership |
| **Inconsistent API** | Each function uses different argument styles and error semantics |
| **Over-abstraction** | Indirection with no reuse, testability, or boundary benefit |

## Example: Email Service (Simple)

```ts
// emailService.ts — shared mechanics
export async function sendWelcomeEmail(params: { to: string; name: string }) {
  const html = `<h1>Welcome ${params.name}</h1>`;
  await emailProvider.send(params.to, "Welcome", html);
}

// userSignup.ts — orchestration (owns WHEN to send)
if (user.marketingOptIn) {
  await sendWelcomeEmail({ to: user.email, name: user.name });
}

// adminInvite.ts — orchestration (different business rule, same mechanic)
await sendWelcomeEmail({ to: invitee.email, name: invitee.name });
```

## Mental Model

```
Existing architecture? → Follow its boundaries
No convention? → Prefer actions for orchestration and services for operations
Extraction? → Name its concrete benefit before adding another layer
```

Keep responsibilities clear, dependencies explicit, and side effects visible.

Attribution

jaydubya818jaydubya818
View sourceMore from jaydubya818 →
SSkills DirectorySkills Directory

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

Related Skills

Caveman

Ultra-compressed communication mode that cuts output tokens while keeping technical accuracy. Levels: lite, full, ultra and the wenyan variants. Use for /caveman, "caveman mode", "talk like caveman", "be brief" or "less tokens".

1074701 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

693161 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3351 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

691 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →