react-human-made
Human Made React Standards
Component Style
- Use functional components with hooks for most cases
- Class components only when required by external libraries
- Keep components focused and single-purpose
- Extract complex logic into custom hooks
Semantic HTML
- Use semantic HTML5 elements (
<article>,<section>,<nav>, etc.) onClickhandlers only on focusable elements (buttons, links)- Ensure keyboard accessibility for interactive elements
- Use ARIA attributes when semantic HTML is insufficient
Props and State
- Specify PropTypes for all component properties
- Prefer props over state; lift state up when needed
- Avoid storing state in DOM
- Use controlled components for form inputs
Component Organization
- Co-locate styles and tests with components
- One component per file for significant components
- Small helper components can share a file with their parent
Example Component
import PropTypes from 'prop-types';
import { useState, useCallback } from 'react';
const UserCard = ( { user, onSelect } ) => {
const [ isExpanded, setIsExpanded ] = useState( false );
const handleToggle = useCallback( () => {
setIsExpanded( prev => ! prev );
}, [] );
return (
<article className="user-card">
<h3>{ user.name }</h3>
<button onClick={ handleToggle }>
{ isExpanded ? 'Collapse' : 'Expand' }
</button>
{ isExpanded && (
<div className="user-card__details">
<p>{ user.email }</p>
<button onClick={ () => onSelect( user.id ) }>
Select User
</button>
</div>
) }
</article>
);
};
UserCard.propTypes = {
user: PropTypes.shape( {
id: PropTypes.number.isRequired,
name: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
} ).isRequired,
onSelect: PropTypes.func.isRequired,
};
export default UserCard;
WordPress Block Editor
When building Gutenberg blocks:
- Use
@wordpress/elementfor React (it re-exports React) - Use
@wordpress/componentsfor UI primitives - Use
@wordpress/block-editorfor block-specific components - Follow the block.json schema for block registration
- Use
@wordpress/datafor state management with WordPress stores
More from humanmade/claude-code-standards
css-scss-human-made
Human Made CSS and SCSS standards. Apply when writing styles, reviewing CSS/SCSS, or working on theme styling. Covers BEM naming, CSS custom properties, theme.json integration, and Stylelint configuration.
20php-human-made
Human Made PHP coding standards for WordPress development. Apply when writing PHP, reviewing PHP code, or working on WordPress plugins and themes. Covers PHPCS HM-Minimum ruleset, namespacing conventions, bootstrap patterns, type hints, and file organization.
1run-linters
Discover and run code linters for the current project. Use when asked to lint code, check code quality, run static analysis, or after completing a feature. Detects PHPCS, PHPStan, ESLint, and Stylelint configurations and runs appropriate checks.
1javascript-human-made
Human Made JavaScript coding standards. Apply when writing JavaScript or TypeScript, reviewing JS code, or working on frontend features. Covers ES6+ conventions, modern patterns, and ESLint configuration.
1hm-coding-philosophy
Human Made engineering principles and code quality standards. Apply when writing code, reviewing code, planning implementations, or discussing architecture. Covers code quality priorities, simplicity over complexity, and avoiding over-engineering.
1