code-architecture
Skill1 starsChanged 3 months agoMITView on GitHub
Layered service-oriented system design, dependency injection boundaries, circular import elimination, and separation of business logic from I/O.
- Reads credentials
7 other projects use a version of this.
Adopted by
Most recently taken up by
- ag2ai/faststreamtheir own version, first seen Oct 8, 2026
- badjano/skillstheir own version, first seen Oct 5, 2026
- kleosr/bridletheir own version, first seen Sep 29, 2026
- kleosr/kleosrulestheir own version, first seen Sep 29, 2026
- nesco/skillstheir own version, first seen Apr 10, 2026
- dhriyatinandu-bot/claude-skillstheir own version, first seen Mar 5, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- ag2ai/faststream★ 5.4ksame name
- badjano/skills★ 1same name
- codyrao/agent-skills★ 1same name
- kleosr/bridle★ 1same name
- kleosr/kleosrules★ 1same name
- dhriyatinandu-bot/claude-skills★ 0same name
- nesco/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adr-managementSkill
- agentic-developmentSkill
- ci-cdSkill
- database-postgresqlSkill
- data-engineeringSkill
- debuggingSkill
- deep-learningSkill
- dependency-managementSkill
- deploymentSkill
- dockerSkill
- documentation-orchestratorSkill
- documentationSkill
- environment-guardrailsSkill
- frontend-react-typescriptSkill
- git-githubSkill
- machine-learningSkill
- observabilitySkill
- performance-optimizationSkill
- portfolio-readinessSkill
- project-bootstrapSkill
- project-knowledgeSkill
- python-apiSkill
- python-environmentSkill
- rag-ocr-llmSkill
- release-engineeringSkill
- reusable-componentsSkill
- security-secretsSkill
- supply-chain-securitySkill
- testing-qualitySkill
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 4 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Use this skill when:
- Distinctive: line 16
Do NOT use this skill for trivial one-line bug fixes that do not alter system structure.
- Distinctive: line 26
Current Dependency Flow: Check import statements across modules.
- Very specific: line 27
Existing Shared Utilities: Check utils/, core/, common/, lib/ to avoid reinventing existing patterns.
- Very specific: line 28
Configuration Access: Ensure configuration is injected or sourced via a unified settings module (e.g.
- Distinctive: line 137
NEVER leak DB sessions into API routes: Avoid querying raw SQLAlchemy models directly inside endpoint handlers.
- Very specific: line 140
NEVER perform direct I/O in constructors: Keep __init__ lightweight and deterministic.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Architecture Skill
1. When Should I Use This?
Use this skill when:
- Structuring or refactoring a backend API, service layer, data processing pipeline, or frontend feature.
- Designing interactions between endpoints, business logic, databases, external APIs, and ML models.
- Resolving circular imports, monolithic god-files, or tightly coupled components.
- Establishing clean architectural boundaries before writing complex features.
Do NOT use this skill for trivial one-line bug fixes that do not alter system structure.
2. What Should I Inspect First?
- Existing Architecture Style:
- Is it layered (API ↔ Service ↔ Repository ↔ Model)?
- Is it Hexagonal / Ports & Adapters?
- Is it Feature-Sliced (Frontend:
features/auth/,features/documents/)?
- Current Dependency Flow: Check import statements across modules. Identify where I/O, DB sessions, and external HTTP clients are instantiated.
- Existing Shared Utilities: Check
utils/,core/,common/,lib/to avoid reinventing existing patterns. - Configuration Access: Ensure configuration is injected or sourced via a unified settings module (e.g.
core/config.py), not scatteredos.getenvcalls.
3. What Workflow Should I Follow?
Map Architectural Boundaries
↓
Search Existing Code for Equivalent Services / Helpers
↓
Separate Business Logic from I/O & Transport
↓
Define Clean Type / Interface Contracts (Pydantic / TS Interfaces)
↓
Implement Domain Logic with Dependency Injection
↓
Wire into API / Transport Layer
↓
Verify Independence with Unit TestsThe Standard 4-Layer Backend Architecture
┌─────────────────────────────────────────────────────────────┐
│ 1. API / Transport Layer (routes, controllers, endpoints) │
│ - Handles HTTP, query params, auth tokens, status codes │
│ - Validates request schemas; serializes response schemas │
└──────────────────────────────┬──────────────────────────────┘
│ calls
┌──────────────────────────────▼──────────────────────────────┐
│ 2. Service / Domain Layer (business logic, orchestration) │
│ - Pure domain operations, business validation, workflows │
│ - NO direct knowledge of HTTP status codes or FastAPI req │
└──────────────────────────────┬──────────────────────────────┘
│ calls via DI
┌──────────────────────────────▼──────────────────────────────┐
│ 3. Data Access / Repository Layer (SQLAlchemy, Prisma, SDK) │
│ - DB queries, transactions, vector store lookups │
└──────────────────────────────┬──────────────────────────────┘
│ operates on
┌──────────────────────────────▼──────────────────────────────┐
│ 4. Core / Domain Models & Config │
│ - DB entities, Pydantic schemas, settings, exceptions │
└─────────────────────────────────────────────────────────────┘Concrete Dependency Injection Pattern (Python)
# app/services/document_service.py
from app.models.document import Document
from app.schemas.document import DocumentCreate
from typing import Protocol
class DocumentRepository(Protocol):
def get_by_id(self, doc_id: str) -> Document | None: ...
def save(self, doc: Document) -> Document: ...
class DocumentService:
def __init__(self, repo: DocumentRepository, ocr_client) -> None:
self.repo = repo
self.ocr_client = ocr_client
def process_and_store(self, user_id: str, file_bytes: bytes, filename: str) -> Document:
# 1. Pure domain logic
extracted_text = self.ocr_client.extract_text(file_bytes)
if not extracted_text.strip():
raise ValueError("Document contains no readable text.")
doc = Document(user_id=user_id, filename=filename, content=extracted_text)
return self.repo.save(doc)# app/api/v1/routes/documents.py (FastAPI wiring)
from fastapi import APIRouter, Depends, HTTPException, UploadFile, status
from app.api.v1.dependencies.services import get_document_service
from app.services.document_service import DocumentService
router = APIRouter(prefix="/documents", tags=["documents"])
@router.post("/", status_code=status.HTTP_201_CREATED)
async def upload_document(
file: UploadFile,
service: DocumentService = Depends(get_document_service)
):
try:
content = await file.read()
return service.process_and_store(user_id="u_123", file_bytes=content, filename=file.filename)
except ValueError as e:
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(e))4. What Decisions Should I Make?
| Architectural Question | Guiding Heuristic |
| Where does this code belong? | If it handles request/status_code → API Layer.<br>If it calculates, transforms, or validates business rules → Service Layer.<br>If it executes raw SQL/ORM operations → Repository/Data Layer.<br>If it parses .env → Core Config. |
| Async vs Sync | Use async for I/O-bound tasks (database queries, network requests, SSE streaming). Use synchronous threads/processes or background workers for heavy CPU-bound tasks (OCR parsing, ML inference). |
| File Sizing | Keep modules under 300-400 lines. If a file grows beyond 400 lines, extract sub-services, routers, or helper modules. |
5. What Should I Avoid?
- NEVER leak DB sessions into API routes: Avoid querying raw SQLAlchemy models directly inside endpoint handlers.
- NEVER import API schemas into database models: Maintain unidirectional dependencies (API → Services → Models/Core).
- NEVER use circular imports: Refactor shared type definitions or protocols into a dedicated
types.pyorschemas/common.py. - NEVER perform direct I/O in constructors: Keep
__init__lightweight and deterministic; instantiate network/file handles in startup lifecycle hooks or explicit connection methods.
6. How Should I Verify Success?
# 1. Verify that domain logic is testable without a real database/HTTP server
pytest tests/unit/test_services.py -v
# 2. Check for circular imports and module integrity
python -c "import app.main; print('Architecture import graph clean')"
# 3. Verify clean typing boundaries with Ruff / mypy
mypy app/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
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.

