elegant-architecture

elegant-architecture is a skill for Claude Code, Codex from majiayu000/spellbook. It costs 43 tokens per session (1,705 once invoked), scanned A, original, MIT.

A software design guide that encourages small, focused files, clear module boundaries, planned structure, and tests of actual behavior.

In plain words
What is it for?
It helps plan new features, split oversized files, define interfaces, separate responsibilities, and organize shared code with real tests.
Why use it?
It helps prevent large, tangled modules and makes code easier to understand and change.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps plan new features, split oversized files, define interfaces, separate responsibilities, and organize shared code with real tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/majiayu000/spellbook/elegant-architecture
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add majiayu000/spellbook --skill elegant-architecture
Clone the repo
git clone --depth 1 https://github.com/majiayu000/spellbook

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for elegant-architecture

README.md
[![agentmods](https://agentmods.dev/badge/skills/majiayu000/spellbook/elegant-architecture/github.svg)](https://agentmods.dev/skills/majiayu000/spellbook/elegant-architecture)
Your own site
<a href="https://agentmods.dev/skills/majiayu000/spellbook/elegant-architecture"><img src="https://agentmods.dev/badge/skills/majiayu000/spellbook/elegant-architecture/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for elegant-architecture

Your own site · 80×15
<a href="https://agentmods.dev/skills/majiayu000/spellbook/elegant-architecture"><img src="https://agentmods.dev/badge/skills/majiayu000/spellbook/elegant-architecture.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,705 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00043 $0.01705
Opus 5 $0.00022 $0.00852
Sonnet 5 $0.00009 $0.00341
Haiku 4.5 $0.00004 $0.00170

Measured 12d ago against content hash e7c3a12d8989, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

elegant-architecture scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/elegant-architecture/SKILL.md · 299 lines

How it starts

The opening of the file, as written. The whole thing — 299 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Elegant Architecture

Core Principles

  • 200-line limit — No file exceeds 200 lines of code
  • Split when exceeded — Convert to folder or multiple files
  • Plan first, code later — Design architecture before implementation
  • Single responsibility — Each module does one thing well
  • Real tests only — No mocks, test actual behavior

Execution Flow

1. Analyze Requirements

Before writing any code:
- List all features/functionalities needed
- Estimate code volume for each module
- Identify shared components
- Map dependencies between modules

2. Design File Structure

When estimated lines > 200:
- Convert file to folder with index
- Split by sub-functionality
- Extract shared utilities

Example transformation:
# Before (user.ts - 400+ lines)
user.ts

# After (user/ folder)
user/
├── index.ts        # Public exports
├── types.ts        # Interfaces, types
├── validation.ts   # Input validation
├── repository.ts   # Data access
└── service.ts      # Business logic

3. Define Interfaces First

// Define contracts before implementation
interface UserService {
  create(input: CreateUserInput): Promise<User>;
  findById(id: string): Promise<User | null>;
  update(id: string, input: UpdateUserInput): Promise<User>;
  delete(id: string): Promise<void>;
}

interface UserRepository {
  save(user: User): Promise<User>;
  findById(id: string): Promise<User | null>;
  findByEmail(email: string): Promise<User | null>;
  delete(id: string): Promise<void>;
}

4. Implement Incrementally

For each module:
1. Create type definitions
2. Implement core logic
3. Add error handling
4. Write tests
5. Verify line count < 200

5. Test Without Mocks

// ❌ Avoid: Mock everything
const mockRepo = jest.fn();
const service = new UserService(mockRepo);

// ✅ Prefer: Real implementations
const testDb = createTestDatabase();
const repo = new UserRepository(testDb);
const service = new UserService(repo);

// Test actual behavior
const user = await service.create({ email: '[email protected]' });
const found = await service.findById(user.id);
expect(found).toEqual(user);

Read the full file on GitHub · 299 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 299 lines · 43 tokens per session scan A e7c3a12d8989

Subscribe to this mod's changes

elegant-architecture is a skill published in the GitHub repository majiayu000/spellbook (278 stars, last pushed yesterday), licensed MIT. It adds 43 tokens to every session and 1,705 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.