AgentSkillsCN

bulletproof-react-auditor

当用户咨询React项目结构、探讨“防弹React”模式,或寻求架构指导时,可积极运用此技能。该技能涵盖结构搭建、代码库审计、反模式检测,以及基于功能的迁移规划。触发关键词包括:“防弹React”“React结构答疑”“整理React应用”“审计我的架构”。

SKILL.md
--- frontmatter
name: bulletproof-react-auditor
description: Use PROACTIVELY when users ask about React project structure, Bulletproof React patterns, or need architecture guidance. Covers structure setup, codebase auditing, anti-pattern detection, and feature-based migration planning. Triggers on "bulletproof react", "React structure help", "organize React app", or "audit my architecture".

Bulletproof React Auditor

Audits React/TypeScript codebases against Bulletproof React architecture with migration planning.

When to Use

Natural Language Triggers (semantic matching, not keywords):

  • Questions about React project structure or organization
  • Mentions of "bulletproof react" or feature-based architecture
  • Requests to audit, review, or improve React codebase
  • Planning migrations or refactoring React applications
  • Seeking guidance on component patterns or folder structure

Use Cases:

  • Setting up new React project structure
  • Reorganizing existing flat codebase
  • Auditing architecture against Bulletproof standards
  • Planning migration to feature-based patterns
  • Code review for structural anti-patterns
  • Generating refactoring guidance and ADRs

Bulletproof Structure Target

code
src/
├── app/           # Routes, providers
├── components/    # Shared components ONLY
├── config/        # Global config
├── features/      # Feature modules (most code)
│   └── feature/
│       ├── api/
│       ├── components/
│       ├── hooks/
│       ├── stores/
│       └── types/
├── hooks/         # Shared hooks
├── lib/           # Third-party configs
├── stores/        # Global state
├── testing/       # Test utilities
├── types/         # Shared types
└── utils/         # Shared utilities

Audit Categories

CategoryKey Checks
StructureFeature folders, cross-feature imports, boundaries
ComponentsSize (<300 LOC), props (<10), composition
StateAppropriate categories, localization, server cache
API LayerCentralized client, types, React Query/SWR
TestingTrophy (70/20/10), semantic queries, behavior
StylingConsistent approach, component library
ErrorsBoundaries, interceptors, tracking
PerformanceCode splitting, memoization, bundle size
SecurityJWT cookies, RBAC, XSS prevention
StandardsESLint, Prettier, TS strict, Husky

Usage Examples

code
# Basic audit
Audit this React codebase using bulletproof-react-auditor.

# Structure focus
Run structure audit against Bulletproof React patterns.

# Migration plan
Generate migration plan to Bulletproof architecture.

# Custom scope
Audit focusing on structure, components, and state management.

Output Formats

  1. Markdown Report - ASCII diagrams, code examples
  2. JSON Report - Machine-readable for CI/CD
  3. Migration Plan - Roadmap with effort estimates

Priority Levels

PriorityExamplesTimeline
P0 CriticalSecurity vulns, breaking issuesImmediate
P1 HighFeature folder creation, reorgThis sprint
P2 MediumState refactor, API layerNext quarter
P3 LowStyling, docs, polishBacklog

Connor's Standards Enforced

  • TypeScript strict mode (no any)
  • 80%+ test coverage
  • Testing trophy: 70% integration, 20% unit, 10% E2E
  • No console.log in production
  • Semantic queries (getByRole preferred)

Best Practices

  1. Fix folder organization before component refactoring
  2. Extract features before other changes
  3. Maintain test coverage during migration
  4. Incremental migration, not all at once
  5. Document decisions with ADRs

Limitations

  • Static analysis only
  • Requires React 16.8+ (hooks)
  • Best for SPA/SSG (Next.js differs)
  • Large codebases need scoped analysis

Resources

References

See reference/ for:

  • Complete Bulletproof principles guide
  • Detailed audit criteria checklist
  • Migration patterns and examples
  • ADR templates