clean-code-pattern-1-responsibility-split-most-common
Sub-skill of clean-code: Pattern 1: Responsibility Split (most common) (+5).
Best use case
clean-code-pattern-1-responsibility-split-most-common is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Sub-skill of clean-code: Pattern 1: Responsibility Split (most common) (+5).
Teams using clean-code-pattern-1-responsibility-split-most-common should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/pattern-1-responsibility-split-most-common/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How clean-code-pattern-1-responsibility-split-most-common Compares
| Feature / Agent | clean-code-pattern-1-responsibility-split-most-common | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Sub-skill of clean-code: Pattern 1: Responsibility Split (most common) (+5).
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Pattern 1: Responsibility Split (most common) (+5)
## Pattern 1: Responsibility Split (most common)
```
# BEFORE: one 1200-line file
src/digital_model/bsee/analysis.py ← does: fetch + parse + validate + report
# AFTER: four focused files
src/digital_model/bsee/
fetcher.py ← HTTP, pagination, rate-limiting (≤150L)
parser.py ← raw→structured data transform (≤200L)
validator.py ← business rules, schema checks (≤150L)
reporter.py ← HTML/CSV/JSON report generation (≤200L)
__init__.py ← re-exports public API (≤30L)
```
## Pattern 2: Extract Report Generator
Report generation always violates SRP when mixed with domain logic.
```python
# BEFORE: domain class with 300-line report method
class WellDataAnalyzer:
def generate_report(self, ...): # 300 lines of HTML templating
...
# AFTER: separate reporter
class WellDataAnalyzer:
def analyze(self, ...) -> AnalysisResult: # pure domain logic
...
class WellDataReporter: # src/<pkg>/<domain>/reporter.py
def generate(self, result: AnalysisResult) -> str:
...
```
## Pattern 3: Extract Constants and Config
Inlined magic numbers bloat files and hide domain knowledge.
```python
# BEFORE
def check_wall_thickness(t, D, SMYS):
if t / D < 0.01: # magic ratio
...
safety_factor = 1.25 # magic number
# AFTER — constants.py (≤50 lines)
WALL_RATIO_MIN = 0.01 # API 5L minimum D/t ratio
DESIGN_SAFETY_FACTOR = 1.25 # ASME B31.4 Table 403.2.1
# domain file uses named constants
from .constants import WALL_RATIO_MIN, DESIGN_SAFETY_FACTOR
```
## Pattern 4: Extract Sub-Package for Large Domains
When a domain grows beyond 3–4 files, promote to sub-package:
```
# BEFORE
src/digitalmodel/structural/
pipe_capacity.py (1476 lines) ← God Object
# AFTER
src/digitalmodel/structural/pipe_capacity/
__init__.py ← public API (re-exports)
models.py ← dataclasses, enums
burst.py ← burst pressure checks
collapse.py ← external pressure / collapse
bending.py ← combined bending checks
api_5l.py ← API 5L specific rules
dnv_st_f101.py ← DNV-ST-F101 specific rules
```
## Pattern 5: Horizontal Split with Shared Shim
When a single file has many functions of the same *type* (e.g., 14 HTML builder functions),
split horizontally by sub-domain, keep the original as a pure re-export shim.
```
# BEFORE: report_builders.py (954 lines) — 14 _build_*_html() functions
# mixed: header/TOC + hydrostatics + responses + appendices
# AFTER: three focused files + shim
report_builders_header.py (352L) ← header, TOC, executive summary, hull description
report_builders_hydrostatics.py(390L) ← stability, natural periods, added mass, damping, coupling
report_builders_responses.py (272L) ← load RAOs, roll damping, phase guide, appendices
report_builders.py (25L) ← shim: re-exports all three sub-modules
```
```python
# report_builders.py (shim)
"""Split into report_builders_header/hydrostatics/responses. Re-exported for compat."""
from .report_builders_header import * # noqa: F401,F403
from .report_builders_hydrostatics import * # noqa: F401,F403
from .report_builders_responses import * # noqa: F401,F403
```
Key rule: each sub-file imports only from upstream data/model modules — never from sibling
builder sub-files. The shim is the only file that imports from all three.
## Pattern 6: Re-export Chain for Layered Helpers
When a large file has callers that import helpers *through* it, preserve that import path
using a re-export chain. Callers need not be updated.
```
# benchmark_rao_plots.py was 699L:
# 5 plot functions + 15 helper functions (get_x_values, add_solver_traces, etc.)
# AFTER split:
benchmark_rao_helpers.py (237L) ← helper functions (leaf module)
benchmark_rao_summary.py (218L) ← summary/table functions
benchmark_rao_plots.py (291L) ← 5 plot functions + re-exports helpers/summary
# benchmark_correlation.py imports from benchmark_rao_plots — no change needed:
from .benchmark_rao_plots import add_solver_traces, get_heading_indices # still works
```
```python
# benchmark_rao_plots.py (reduced + re-exports)
from .benchmark_rao_helpers import ( # noqa: F401
add_solver_traces, apply_layout, get_heading_indices,
get_significant_heading_indices, get_solver_style,
get_x_values, save_figure, x_axis_label,
)
from .benchmark_rao_summary import ( # noqa: F401
build_summary_table, compute_amplitude_summary,
compute_phase_summary, render_html_with_table,
)
# ... 5 plot functions remain here
```
---Related Skills
mnt-analysis-cleanup
Survey, classify, and clean up `/mnt/local-analysis/` (or any sibling-to-workspace-hub directory holding orphan worktrees, codex-burn artifacts, agent log accumulations, and outer-clone duplicates) without losing useful code/work. Surfaces a tiered approval menu rather than baking decisions; defers all destructive ops until user confirms.
orcaflex-reporting-fixture-proof-pattern
Build and extend fixture-backed OrcaFlex reporting proof paths in digitalmodel using stable metadata baselines, normalized HTML snapshots, and reusable reporting test helpers.
pre-completion-cleanup-audit
Audit and dispose of session residue (orphan files, scratch dirs, sibling-repo state, locks, trash-stages) BEFORE claiming a task complete. Required gate before any agent says "all done", "task complete", or hands work back to user/orchestrator.
taxact-browser-automation-patterns
Patterns for automating TaxAct Business online (Ionic SPA) via Chrome browser MCP tools — field interaction, navigation, shadow DOM handling
portable-pattern-verification-workflow
Multi-package implementation with verification strategy for cross-platform configuration hardening
portable-config-baseline-pattern
Extract machine-agnostic settings into portable template files while keeping machine-specific hooks and plugins separate
portable-baseline-pattern-implementation
Implement portable configuration baselines by separating machine-agnostic settings from machine-specific hooks and plugins
portable-baseline-pattern-extraction
Extract and separate portable baseline config from machine-specific overrides in multi-environment projects
portable-baseline-configuration-pattern
Separate portable/universal config from machine-specific settings to enable safe template reuse across environments
portable-baseline-config-pattern
Separate machine-portable baseline config from environment-specific hooks and plugins
parallel-array-alignment-pattern
Maintain index synchronization between parallel arrays when adding new entries to preserve label-path mappings
gsd-adversarial-review-pattern
Catch hidden test failures by running adversarial review on sparse-data edge cases before final push