Skip to content

Add Claude skills for business logic separation and no-barrel-exports#6279

Open
lkostrowski wants to merge 4 commits intomainfrom
claude-skill-logic-outside-ui
Open

Add Claude skills for business logic separation and no-barrel-exports#6279
lkostrowski wants to merge 4 commits intomainfrom
claude-skill-logic-outside-ui

Conversation

@lkostrowski
Copy link
Member

@lkostrowski lkostrowski commented Jan 27, 2026

Summary

  • Adds a separate-business-logic Claude skill that enforces extracting business logic from React components into standalone, testable utility files following a logic → hook → component pattern
  • Adds a no-barrel-exports Claude skill that prevents creation of index.ts/index.tsx barrel files and enforces direct imports from source files

Both skills align with existing conventions documented in CLAUDE.md and provide structured guidance for Claude Code when writing or refactoring code in this repository.

Changes

  • .claude/skills/separate-business-logic/SKILL.md — New skill with rules for extracting data transformations, validation, formatting, and conditional logic out of components, along with file naming conventions, testing expectations, and examples
  • .claude/skills/no-barrel-exports/SKILL.md — New skill enforcing direct imports instead of barrel re-exports, with clear exceptions for route entry points

Test plan

  • Verify skills are recognized by Claude Code in this repository
  • Test that the separate-business-logic skill triggers when refactoring a component with inlined logic
  • Test that the no-barrel-exports skill triggers when creating new components or modules

@lkostrowski lkostrowski requested a review from a team as a code owner January 27, 2026 08:43
@lkostrowski lkostrowski requested review from Copilot and witoszekdev and removed request for Copilot January 27, 2026 08:43
@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2026

⚠️ No Changeset found

Latest commit: 729053a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@lkostrowski lkostrowski changed the title Add claude skill for business logic separation Add Claude skills for business logic separation and no-barrel-exports Jan 27, 2026
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.34%. Comparing base (57cef53) to head (729053a).

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #6279     +/-   ##
=========================================
  Coverage   42.34%   42.34%             
=========================================
  Files        2469     2469             
  Lines       42106    42106             
  Branches     9721     9721             
=========================================
  Hits        17831    17831             
- Misses      23011    24244   +1233     
+ Partials     1264       31   -1233     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: for enforcement SKILLS are brittle, claude loads them dynamically - it might load or not and it can just straight up ignore it 😄. It's better to use them to perform certain tasks in a way we want (e.g. separate business logic)

Maybe we could rewrite this to a hook instead? This way we can check if Claude edits / creates index.ts / index.tsx and return an error there to force it to not create such files programatically

Example:

Blocks the edit if 'as any' is detected in the new content.


## What Counts as Business Logic

- Data mapping and transformations (e.g., converting API responses to UI models)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: let's add a description so that it doesn't overengineer data mapping - a simple data.map() in JSX is fine imho, if we don't calculate new values just render a list for example

- Filtering, sorting, grouping collections
- Validation rules and error message resolution
- Conditional logic that determines what to display or which action to take
- Formatting (dates, currencies, percentages, labels)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: we should use react-intl for formatting most of the time, so maybe let's also add a note? otherwise i suspect we might end up with more and more utility functions that are built into libraries we already use

├── useComponentName.ts # Hook (optional, bridges logic → component)
├── componentNameUtils.ts # Pure logic functions
├── componentNameUtils.test.ts # Unit tests for the logic
└── ComponentName.module.css
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: do we want to move ahead with writing .module.css? I remember we were thinking about using vanilla-extract since macaw-ui is already using it and imho it's a pretty good library, less verbose than css modules and has nice type checking


## Testing Expectations

- Every `*Utils.ts` file must have a corresponding `*.test.ts` file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: let's also add explicitly hooks

Suggested change
- Every `*Utils.ts` file must have a corresponding `*.test.ts` file.
- Every `*Utils.ts` and `use*.ts` file must have a corresponding `*.test.ts` file.

Comment on lines +83 to +114
```typescript
// calculateTotal.test.ts
import { calculateTotal } from "./cartUtils";
import { Item } from "./types";

describe("calculateTotal", () => {
it("sums item prices multiplied by quantity", () => {
// Arrange
const items: Item[] = [
{ price: 10, quantity: 2 },
{ price: 5, quantity: 3 },
];

// Act
const result = calculateTotal(items);

// Assert
expect(result).toBe(35);
});

it("returns 0 for empty list", () => {
// Arrange
const items: Item[] = [];

// Act
const result = calculateTotal(items);

// Assert
expect(result).toBe(0);
});
});
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: maybe we should separate examples into a separate file in a skill directory? This is a good way to save context for specific use cases, e.g. writing test

https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview#level-3-resources-and-code-loaded-as-needed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: in general maybe we should also add instructions about finding existing utilities? I think we have plenty of them (e.g. related to prices) - it would be great if we would re-use that instead of creating more and more code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants