separation-of-concerns

Separate data fetching, business logic, and presentation into hooks, functions, and components.

13|2|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/yanko-belov/code-craft --skill separation-of-concerns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: separation-of-concerns
Source: https://github.com/yanko-belov/code-craft/tree/main/skills/separation-of-concerns
Command: npx skills add https://github.com/yanko-belov/code-craft --skill separation-of-concerns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Mixed concerns in UI code create untestable, hard-to-maintain components. This Skill enforces the Iron Rule: never mix data fetching, business logic, and presentation in a single place.

Core Features & Use Cases

  • Separated data layer: move data fetching into hooks or services.
  • Pure logic layer: implement business rules and data transformations as pure functions.
  • Presentation layer: build dumb UI components that render from props.
  • Composition: use a container to connect layers, handle loading and errors, and compose final UI.
  • Real-world use case: refactor a monolithic UserProfile component into a data hook, a formatter, a presentational card, and a container.

Quick Start

  1. Identify a monolithic component that fetches data, runs logic, and renders UI.
  2. Extract data fetching into a dedicated hook or service.
  3. Move business logic into pure functions that transform data.
  4. Create presentational components that render from props.
  5. Build a container to compose the layers and manage loading and error states.

Frequently Asked Questions about separation-of-concerns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I separate data fetching, business logic, and presentation in React components?

To separate concerns in React components, extract data fetching into dedicated hooks or services, move business logic into pure functions, and build presentational components that render from props. A container then composes these layers and manages loading and error states.

What is the best way to refactor a monolithic component that fetches data and renders UI?

The best way to refactor a monolithic component is enforcing the separation of concerns pattern. Move data fetching into a data hook, extract transformations into a formatter as pure functions, build a presentational card, and use a container to compose them.

Why does mixing data fetching, business logic, and presentation create untestable components?

Mixing data fetching, business logic, and presentation creates untestable components because dependencies are tightly coupled within a single render cycle. Separating them into hooks, pure functions, and presentational components isolates logic for direct testing.

Can I use the container pattern to manage loading and error states across React-like frameworks?

Yes, you can use the container pattern across React-like frameworks to manage loading and error states. The container acts as the composition layer connecting the data, logic, and presentation layers, handling state transitions before rendering the presentational UI.

When do I need to separate concerns into hooks, pure functions, and presentational components?

You need to separate concerns into hooks, pure functions, and presentational components when a UI component simultaneously fetches data, performs transformations, and renders markup. This separation ensures the data layer, logic layer, and presentation layer remain independently maintainable.

What are the limitations of using pure functions for business logic in frontend architecture?

Using pure functions for business logic in frontend architecture limits direct state mutation, requiring all data transformations to return new values. This approach demands a container component to explicitly handle side effects and pass results as props to the presentation layer.