code-structure
Use when multiple workflows duplicate the same operational logic, when deciding what belongs in actions vs shared services, or when refactoring repeated…
Skill by kausthubh-coder
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/kausthubh-coder-code-structure
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/code-structure
What's inside
- Skill name
code-structure- Description
- Use when multiple workflows duplicate the same operational logic, when deciding what belongs in actions vs shared services, or when refactoring repeated operational blocks across domain flows. Use when adding new features that share mechanics with existing ones.
- License
- MIT
- Instructions
- 113 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Service Layer Architecture
## Overview
**Two-layer separation:** Actions orchestrate domain rules (the "why/when"), while a service layer centralizes reusable operational mechanics (the "how").
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
**Don't use when:** Logic is truly domain-specific and used by only one caller.
## 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 params, structured returns | Hidden global state, reaching into DB |
| Migration | Extract one block, replace one caller, verify, then migrate rest | Refactor everything at once |
| Domain logic | Keep auth, policy, error classification in actions | Let service mutate domain state directly |
| Extraction trigger | Logic repeated across 2+ callers | Logic used once (over-abstraction) |
## 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 }`)
- Never reach into database/state directly
- Make failure explicit (structured results, not swallowed errors)
This lets callers choose strict vs relaxed behavior per flow.
## Migration Checklist
When extracting shared logic:
1. Write the flow in action code first (clear behavior)
2. Mark repeated operational chunks across callers
3. Extract **only** repeated, non-domain chunks to service
4. Replace one caller → verify → replace remaining callers
5. Keep domain policy in actions (auth, status transitions, error classification)
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** | Service mutates database tables directly |
| **Inconsistent API** | Each function uses different argument styles and error semantics |
| **Over-abstraction** | Extracting logic used by only one caller |
## 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
```
New feature? → Write in action first → See repeated ops? → Extract to service
→ No repetition? → Keep in action
```
Your architecture in one sentence: **Actions orchestrate domain rules, while the service layer centralizes reusable operational mechanics with a composable, explicit-input API.**From kausthubh-coder/skills, MIT.
More from kausthubh-coder/skills
- 0.570score
create-verification-skill
kausthubh-coder
Set up a repo so agents can run and use the app themselves and prove a change works.
SkillAFreshness: AClaude Code +9 - 0.570score
diagnosing-bugs
kausthubh-coder
Find the real cause of a bug before fixing it.
SkillAFreshness: AClaude Code +9 - 0.567score
cloud
kausthubh-coder
Move this thread's work to my InstaBox cloud machine, or start, steer or check threads there.
SkillAFreshness: AClaude Code +9 - 0.566score
before-and-after
kausthubh-coder
Captures before/after screenshots of web pages or elements for visual comparison.
SkillAFreshness: AClaude Code +9 - 0.566score
oracle
kausthubh-coder
Run the user's agentic engineering workflow with `oracle init`, `oracle plan`, and `oracle implement`: one structured project-local `.artifacts` workspace…
SkillAFreshness: AClaude Code +9 - 0.566score
evidence-driven-testing
kausthubh-coder
Records visual proof while testing UI behavior — the agent tests the app hands-on via computer use while a screen recording with structured test/assertion…
SkillAFreshness: AClaude Code +9 - 0.565score
correct
kausthubh-coder
Make a repeated agent mistake impossible with structure, types, lint or a test.
SkillAFreshness: AClaude Code +9 - 0.565score
benchmark-checklist
kausthubh-coder
Check a perf number before you report or act on it.
SkillAFreshness: AClaude Code +9 - 0.561score
create-formal-verification-skill
kausthubh-coder
Formally verify the riskiest code tests can't reach (races, retries, state machines, parsers) and leave a project skill to recheck it.
SkillAFreshness: AClaude Code +9 - 0.561score
audit-skills
kausthubh-coder
Audit how well my skills worked in my recent threads and update the skills dashboard.
SkillAFreshness: AClaude Code +9 - 0.561score
delegating
kausthubh-coder
Hand work to another agent well, whether a subagent, a T3 thread or Devin.
SkillAFreshness: AClaude Code +9 - 0.560score
cloud-pr
kausthubh-coder
Build a change in a Claude cloud thread, have Devin test the PR on real devices, loop fixes, then ship.
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 14, 2026 (14 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/kausthubh-coder/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from kausthubh-coder
- 0.570score
create-verification-skill
kausthubh-coder
Set up a repo so agents can run and use the app themselves and prove a change works.
SkillAFreshness: AClaude Code +9 - 0.570score
diagnosing-bugs
kausthubh-coder
Find the real cause of a bug before fixing it.
SkillAFreshness: AClaude Code +9 - 0.567score
cloud
kausthubh-coder
Move this thread's work to my InstaBox cloud machine, or start, steer or check threads there.
SkillAFreshness: AClaude Code +9 - 0.566score
before-and-after
kausthubh-coder
Captures before/after screenshots of web pages or elements for visual comparison.
SkillAFreshness: AClaude Code +9 - 0.566score
oracle
kausthubh-coder
Run the user's agentic engineering workflow with `oracle init`, `oracle plan`, and `oracle implement`: one structured project-local `.artifacts` workspace…
SkillAFreshness: AClaude Code +9 - 0.566score
evidence-driven-testing
kausthubh-coder
Records visual proof while testing UI behavior — the agent tests the app hands-on via computer use while a screen recording with structured test/assertion…
SkillAFreshness: AClaude Code +9
Cite this page
code-structure skill. Agent Mart. https://agentmart.dev/skills/kausthubh-coder-code-structure (last updated 2026-10-24)