@defai.digital/automatosx 5.0.13 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/README.md +310 -92
  3. package/dist/index.js +7784 -6097
  4. package/dist/index.js.map +1 -1
  5. package/dist/version.json +3 -3
  6. package/examples/AGENTS_INFO.md +495 -0
  7. package/examples/README.md +434 -0
  8. package/examples/abilities/accessibility.md +115 -0
  9. package/examples/abilities/api-design.md +159 -0
  10. package/examples/abilities/best-practices.md +102 -0
  11. package/examples/abilities/caching-strategy.md +165 -0
  12. package/examples/abilities/ci-cd.md +61 -0
  13. package/examples/abilities/code-generation.md +95 -0
  14. package/examples/abilities/code-review.md +42 -0
  15. package/examples/abilities/component-architecture.md +112 -0
  16. package/examples/abilities/content-creation.md +97 -0
  17. package/examples/abilities/data-modeling.md +171 -0
  18. package/examples/abilities/data-validation.md +50 -0
  19. package/examples/abilities/db-modeling.md +158 -0
  20. package/examples/abilities/debugging.md +43 -0
  21. package/examples/abilities/dependency-audit.md +60 -0
  22. package/examples/abilities/design-system-implementation.md +126 -0
  23. package/examples/abilities/documentation.md +54 -0
  24. package/examples/abilities/error-analysis.md +107 -0
  25. package/examples/abilities/etl-pipelines.md +44 -0
  26. package/examples/abilities/feasibility-study.md +20 -0
  27. package/examples/abilities/general-assistance.md +26 -0
  28. package/examples/abilities/idea-evaluation.md +21 -0
  29. package/examples/abilities/infra-as-code.md +57 -0
  30. package/examples/abilities/job-orchestration.md +44 -0
  31. package/examples/abilities/literature-review.md +19 -0
  32. package/examples/abilities/logical-analysis.md +21 -0
  33. package/examples/abilities/longform-report.md +25 -0
  34. package/examples/abilities/observability.md +61 -0
  35. package/examples/abilities/our-architecture-decisions.md +180 -0
  36. package/examples/abilities/our-code-review-checklist.md +149 -0
  37. package/examples/abilities/our-coding-standards.md +270 -0
  38. package/examples/abilities/our-project-structure.md +175 -0
  39. package/examples/abilities/performance-analysis.md +56 -0
  40. package/examples/abilities/performance.md +80 -0
  41. package/examples/abilities/problem-solving.md +50 -0
  42. package/examples/abilities/refactoring.md +49 -0
  43. package/examples/abilities/release-strategy.md +58 -0
  44. package/examples/abilities/risk-assessment.md +19 -0
  45. package/examples/abilities/secrets-policy.md +61 -0
  46. package/examples/abilities/secure-coding-review.md +51 -0
  47. package/examples/abilities/security-audit.md +65 -0
  48. package/examples/abilities/sql-optimization.md +84 -0
  49. package/examples/abilities/state-management.md +96 -0
  50. package/examples/abilities/task-planning.md +65 -0
  51. package/examples/abilities/technical-writing.md +77 -0
  52. package/examples/abilities/testing.md +47 -0
  53. package/examples/abilities/threat-modeling.md +49 -0
  54. package/examples/abilities/troubleshooting.md +80 -0
  55. package/examples/agents/.tmp +0 -0
  56. package/examples/agents/backend.yaml +69 -0
  57. package/examples/agents/ceo.yaml +60 -0
  58. package/examples/agents/cto.yaml +59 -0
  59. package/examples/agents/data.yaml +77 -0
  60. package/examples/agents/design.yaml +73 -0
  61. package/examples/agents/devops.yaml +82 -0
  62. package/examples/agents/frontend.yaml +74 -0
  63. package/examples/agents/product.yaml +69 -0
  64. package/examples/agents/quality.yaml +70 -0
  65. package/examples/agents/researcher.yaml +71 -0
  66. package/examples/agents/security.yaml +84 -0
  67. package/examples/agents/writer.yaml +77 -0
  68. package/examples/claude/commands/ax:agent.md +37 -0
  69. package/examples/claude/commands/ax:clear.md +22 -0
  70. package/examples/claude/commands/ax:init.md +25 -0
  71. package/examples/claude/commands/ax:list.md +19 -0
  72. package/examples/claude/commands/ax:memory.md +25 -0
  73. package/examples/claude/commands/ax:status.md +24 -0
  74. package/examples/claude/commands/ax:update.md +28 -0
  75. package/examples/claude/mcp/automatosx.json +244 -0
  76. package/examples/teams/business.yaml +56 -0
  77. package/examples/teams/core.yaml +59 -0
  78. package/examples/teams/design.yaml +58 -0
  79. package/examples/teams/engineering.yaml +69 -0
  80. package/examples/teams/research.yaml +56 -0
  81. package/examples/templates/analyst.yaml +60 -0
  82. package/examples/templates/assistant.yaml +48 -0
  83. package/examples/templates/basic-agent.yaml +28 -0
  84. package/examples/templates/code-reviewer.yaml +52 -0
  85. package/examples/templates/debugger.yaml +63 -0
  86. package/examples/templates/designer.yaml +69 -0
  87. package/examples/templates/developer.yaml +60 -0
  88. package/examples/templates/fullstack-developer.yaml +395 -0
  89. package/examples/templates/qa-specialist.yaml +71 -0
  90. package/examples/use-cases/01-web-app-development.md +374 -0
  91. package/package.json +2 -1
  92. package/version.json +3 -3
@@ -0,0 +1,80 @@
1
+ # Frontend Performance Optimization
2
+
3
+ Optimize React applications for speed and efficiency.
4
+
5
+ ## Core Web Vitals
6
+
7
+ Target metrics:
8
+ - **LCP** (Largest Contentful Paint): < 2.5s
9
+ - **FID** (First Input Delay): < 100ms
10
+ - **CLS** (Cumulative Layout Shift): < 0.1
11
+ - **FCP** (First Contentful Paint): < 1.8s
12
+ - **TTI** (Time to Interactive): < 3.8s
13
+
14
+ ## Optimization Strategies
15
+
16
+ ### 1. Code Splitting
17
+ - Use React.lazy() for route-based splitting
18
+ - Split heavy components (charts, editors, modals)
19
+ - Use Suspense with meaningful fallbacks
20
+ - Analyze bundle with webpack-bundle-analyzer
21
+
22
+ ### 2. Memoization
23
+ - useMemo() for expensive calculations
24
+ - useCallback() for callbacks passed to child components
25
+ - React.memo() for components that re-render with same props
26
+ - Don't over-memoize (profile first)
27
+
28
+ ### 3. Virtualization
29
+ - Use react-window or react-virtualized for long lists (>100 items)
30
+ - Implement infinite scroll for large datasets
31
+ - Lazy load images in viewport
32
+
33
+ ### 4. Asset Optimization
34
+ - Compress images (WebP format, use srcset)
35
+ - Lazy load images (loading="lazy")
36
+ - Use CDN for static assets
37
+ - Enable gzip/brotli compression
38
+ - Optimize fonts (font-display: swap, preload critical fonts)
39
+
40
+ ### 5. Render Optimization
41
+ - Avoid inline function/object creation in render
42
+ - Use key prop correctly for lists
43
+ - Lift state up sparingly (keep state local when possible)
44
+ - Debounce/throttle expensive operations (search, scroll handlers)
45
+ - Use production build for deployment
46
+
47
+ ### 6. Network Optimization
48
+ - Implement caching strategies (Cache-Control headers)
49
+ - Use service workers for offline support
50
+ - Prefetch critical resources
51
+ - Minimize API calls (batch requests)
52
+ - Use GraphQL field selection to fetch only needed data
53
+
54
+ ### 7. Bundle Optimization
55
+ - Tree-shake unused code
56
+ - Use dynamic imports for conditional features
57
+ - Remove unused dependencies
58
+ - Use lighter alternatives (date-fns instead of moment)
59
+ - Configure webpack to split vendor bundles
60
+
61
+ ## Performance Profiling
62
+
63
+ Tools and techniques:
64
+ - Chrome DevTools Performance tab
65
+ - React DevTools Profiler
66
+ - Lighthouse CI
67
+ - Web Vitals library
68
+ - Bundle analyzer
69
+
70
+ ## Quick Checklist
71
+
72
+ Before deploying:
73
+ - [ ] Bundle size analyzed and optimized
74
+ - [ ] Images compressed and lazy loaded
75
+ - [ ] Long lists virtualized
76
+ - [ ] Expensive computations memoized
77
+ - [ ] Route-based code splitting implemented
78
+ - [ ] Core Web Vitals measured and acceptable
79
+ - [ ] Production build tested
80
+ - [ ] Caching strategy configured
@@ -0,0 +1,50 @@
1
+ # Problem-Solving Ability
2
+
3
+ Systematically approach and solve complex problems.
4
+
5
+ ## Problem-Solving Framework
6
+
7
+ 1. **Define** the problem
8
+ - State the problem clearly
9
+ - Identify root cause (5 Whys)
10
+ - Separate symptoms from causes
11
+ - Define constraints
12
+
13
+ 2. **Analyze** the situation
14
+ - Gather relevant information
15
+ - Identify patterns
16
+ - Consider multiple perspectives
17
+ - List assumptions
18
+
19
+ 3. **Generate** solutions
20
+ - Brainstorm alternatives
21
+ - Don't judge initially (divergent thinking)
22
+ - Consider unconventional approaches
23
+ - Document all ideas
24
+
25
+ 4. **Evaluate** options
26
+ - List pros and cons
27
+ - Consider trade-offs
28
+ - Assess feasibility
29
+ - Estimate impact
30
+
31
+ 5. **Implement** solution
32
+ - Create action plan
33
+ - Start with small experiments
34
+ - Monitor progress
35
+ - Adjust as needed
36
+
37
+ 6. **Review** and learn
38
+ - Did it solve the problem?
39
+ - What worked well?
40
+ - What could be improved?
41
+ - Document lessons learned
42
+
43
+ ## Techniques
44
+
45
+ - **5 Whys**: Dig deeper by asking "why" repeatedly
46
+ - **First Principles**: Break down to fundamental truths
47
+ - **Rubber Duck Debugging**: Explain problem out loud
48
+ - **Divide and Conquer**: Break into smaller sub-problems
49
+ - **Work Backwards**: Start from desired outcome
50
+ - **Analogies**: Apply solutions from similar domains
@@ -0,0 +1,49 @@
1
+ # Refactoring Ability
2
+
3
+ Improve code structure without changing behavior.
4
+
5
+ ## When to Refactor
6
+
7
+ - Before adding new features
8
+ - When code is hard to understand
9
+ - When code has duplications (DRY)
10
+ - When tests are brittle or missing
11
+ - During code review
12
+
13
+ ## Common Refactorings
14
+
15
+ 1. **Extract Function**
16
+ - Break long functions into smaller ones
17
+ - Improve readability and reusability
18
+
19
+ 2. **Rename**
20
+ - Use descriptive names
21
+ - Reflect current purpose
22
+
23
+ 3. **Extract Variable**
24
+ - Name complex expressions
25
+ - Improve readability
26
+
27
+ 4. **Inline**
28
+ - Remove unnecessary abstractions
29
+ - Simplify code flow
30
+
31
+ 5. **Move Method/Function**
32
+ - Improve code organization
33
+ - Reduce coupling
34
+
35
+ ## Refactoring Process
36
+
37
+ 1. Ensure tests are passing
38
+ 2. Make small, incremental changes
39
+ 3. Run tests after each change
40
+ 4. Commit frequently
41
+ 5. Review and validate improvements
42
+
43
+ ## Safety Rules
44
+
45
+ - Never refactor and add features simultaneously
46
+ - Always have tests before refactoring
47
+ - Make one change at a time
48
+ - Run tests frequently
49
+ - Use version control (commit often)
@@ -0,0 +1,58 @@
1
+ # Release Strategy
2
+
3
+ Plan and execute safe, controlled software releases. Use deployment patterns that minimize risk and enable quick rollback.
4
+
5
+ ## Deployment Patterns
6
+
7
+ ### 1. Blue-Green Deployment
8
+ ```bash
9
+ # ✅ Switch traffic instantly
10
+ kubectl apply -f deployment-green.yaml
11
+ curl http://green.example.com/health
12
+ kubectl patch service app -p '{"spec":{"selector":{"version":"green"}}}'
13
+ # Rollback if needed: switch back to blue
14
+ ```
15
+
16
+ ### 2. Canary Deployment
17
+ ```yaml
18
+ # ✅ Good: Gradual rollout (10% canary, 90% stable)
19
+ apiVersion: apps/v1
20
+ kind: Deployment
21
+ metadata:
22
+ name: app-stable
23
+ spec:
24
+ replicas: 9
25
+ ---
26
+ apiVersion: apps/v1
27
+ kind: Deployment
28
+ metadata:
29
+ name: app-canary
30
+ spec:
31
+ replicas: 1
32
+ ```
33
+
34
+ ### 3. Feature Flags
35
+ ```javascript
36
+ // ✅ Good: Gradual feature rollout
37
+ if (featureFlags.isEnabled('new-checkout', user.id)) {
38
+ return <NewCheckout />;
39
+ }
40
+ ```
41
+
42
+ ## Don'ts ❌
43
+
44
+ ```bash
45
+ # ❌ Bad: Big bang release on Friday
46
+ ./deploy-all-changes.sh
47
+ # Go home, hope for best
48
+
49
+ # ❌ Bad: No rollback plan
50
+ ```
51
+
52
+ ## Best Practices
53
+ - Release during low-traffic periods
54
+ - Have documented rollback procedure
55
+ - Use feature flags for risky changes
56
+ - Monitor key metrics during/after release
57
+ - Automate deployment process
58
+ - Document release notes
@@ -0,0 +1,19 @@
1
+ Goal
2
+ - Identify and prioritize risks; propose mitigations and owners.
3
+
4
+ How to do it
5
+ - List risks by category (technical, operational, legal, market).
6
+ - Rate likelihood and impact (Low/Med/High or 1–5).
7
+ - Propose mitigations, triggers, and owners.
8
+
9
+ Do
10
+ - Use a table: Risk | Likelihood | Impact | Mitigation | Owner | Trigger.
11
+ - Include residual risk after mitigation.
12
+
13
+ Don’t
14
+ - Don’t list generic risks without project context.
15
+ - Don’t skip ownership/trigger criteria.
16
+
17
+ Output
18
+ - A prioritized risk register plus a short mitigation plan.
19
+
@@ -0,0 +1,61 @@
1
+ # Secrets Management Policy
2
+
3
+ Securely store, rotate, and access secrets (API keys, passwords, certificates). Never commit secrets to version control.
4
+
5
+ ## Do's ✅
6
+
7
+ ```bash
8
+ # ✅ Good: Environment variables
9
+ export DATABASE_URL="postgresql://user:password@localhost/db"
10
+ export API_KEY="sk_live_abc123"
11
+
12
+ # Access in code
13
+ const dbUrl = process.env.DATABASE_URL;
14
+ ```
15
+
16
+ ```javascript
17
+ // ✅ Good: AWS Secrets Manager
18
+ const AWS = require('aws-sdk');
19
+ const client = new AWS.SecretsManager({ region: 'us-east-1' });
20
+
21
+ async function getSecret(name) {
22
+ const data = await client.getSecretValue({ SecretId: name }).promise();
23
+ return JSON.parse(data.SecretString);
24
+ }
25
+ ```
26
+
27
+ ```
28
+ # ✅ Good: .gitignore secrets
29
+ .env
30
+ .env.local
31
+ secrets/
32
+ *.pem
33
+ *.key
34
+ ```
35
+
36
+ ## Don'ts ❌
37
+
38
+ ```javascript
39
+ // ❌ Bad: Hardcoded secrets
40
+ const API_KEY = "sk_live_abc123xyz";
41
+ const DB_PASSWORD = "SuperSecret123!";
42
+
43
+ // ❌ Bad: Logging secrets
44
+ logger.info('DB connection', { password: dbPassword });
45
+
46
+ // ❌ Bad: Secrets in URLs
47
+ fetch(`https://api.com/data?api_key=${apiKey}`);
48
+ // ✅ Good: In headers
49
+ fetch('https://api.com/data', {
50
+ headers: { 'Authorization': `Bearer ${apiKey}` }
51
+ });
52
+ ```
53
+
54
+ ## Best Practices
55
+ - Never commit secrets to git
56
+ - Use secret management tools (Vault, AWS Secrets Manager)
57
+ - Rotate secrets regularly (90 days)
58
+ - Different secrets for dev/staging/prod
59
+ - Audit secret access
60
+ - Encrypt at rest and in transit
61
+ - Use pre-commit hooks (detect-secrets)
@@ -0,0 +1,51 @@
1
+ # Secure Coding Review
2
+
3
+ Review code for security vulnerabilities using OWASP Top 10 and secure coding standards. Identify and fix flaws before production.
4
+
5
+ ## OWASP Top 10 Examples
6
+
7
+ ### A01: Broken Access Control
8
+ ```javascript
9
+ // ❌ Bad: No authorization
10
+ app.get('/api/users/:id/orders', async (req, res) => {
11
+ const orders = await db.getOrders(req.params.id);
12
+ res.json(orders); // Any user can view any orders!
13
+ });
14
+
15
+ // ✅ Good: Verify ownership
16
+ app.get('/api/users/:id/orders', auth, async (req, res) => {
17
+ if (req.user.id !== parseInt(req.params.id)) {
18
+ return res.status(403).json({ error: 'Forbidden' });
19
+ }
20
+ const orders = await db.getOrders(req.params.id);
21
+ res.json(orders);
22
+ });
23
+ ```
24
+
25
+ ### A02: Cryptographic Failures
26
+ ```javascript
27
+ // ❌ Bad: Weak hashing
28
+ const hash = crypto.createHash('md5').update(password).digest('hex');
29
+
30
+ // ✅ Good: Strong hashing
31
+ const hash = await bcrypt.hash(password, 12);
32
+ ```
33
+
34
+ ### A03: Injection
35
+ ```javascript
36
+ // ❌ Bad: SQL Injection
37
+ const query = `SELECT * FROM users WHERE email = '${email}'`;
38
+
39
+ // ✅ Good: Parameterized query
40
+ const query = 'SELECT * FROM users WHERE email = ?';
41
+ const results = await db.query(query, [email]);
42
+ ```
43
+
44
+ ## Review Checklist
45
+ - ✅ MFA for sensitive actions
46
+ - ✅ Authorization checks on all endpoints
47
+ - ✅ Input validation and sanitization
48
+ - ✅ Parameterized queries
49
+ - ✅ Secrets not hardcoded
50
+ - ✅ TLS 1.2+ required
51
+ - ✅ No sensitive data in logs
@@ -0,0 +1,65 @@
1
+ # Security Audit Ability
2
+
3
+ Identify and mitigate security vulnerabilities in code.
4
+
5
+ ## OWASP Top 10 Focus
6
+
7
+ 1. **Injection Attacks**
8
+ - SQL injection
9
+ - Command injection
10
+ - XSS (Cross-Site Scripting)
11
+ - Prevention: Input validation, parameterized queries
12
+
13
+ 2. **Broken Authentication**
14
+ - Weak passwords
15
+ - Session management issues
16
+ - Missing MFA
17
+ - Prevention: Strong auth mechanisms, secure sessions
18
+
19
+ 3. **Sensitive Data Exposure**
20
+ - Unencrypted data
21
+ - Hardcoded secrets
22
+ - Logging sensitive info
23
+ - Prevention: Encryption, secret management
24
+
25
+ 4. **Access Control**
26
+ - Missing authorization checks
27
+ - Privilege escalation
28
+ - IDOR (Insecure Direct Object References)
29
+ - Prevention: Proper authorization, RBAC
30
+
31
+ 5. **Security Misconfiguration**
32
+ - Default credentials
33
+ - Unnecessary services enabled
34
+ - Debug mode in production
35
+ - Prevention: Secure defaults, hardening
36
+
37
+ ## Security Checklist
38
+
39
+ Input Validation:
40
+
41
+ - [ ] Validate all user inputs
42
+ - [ ] Whitelist > blacklist
43
+ - [ ] Sanitize outputs
44
+ - [ ] Check file upload types and sizes
45
+
46
+ Authentication & Authorization:
47
+
48
+ - [ ] Strong password requirements
49
+ - [ ] Secure session management
50
+ - [ ] Proper authorization checks
51
+ - [ ] Rate limiting on auth endpoints
52
+
53
+ Data Protection:
54
+
55
+ - [ ] Encrypt sensitive data at rest
56
+ - [ ] Use HTTPS for data in transit
57
+ - [ ] No secrets in code/logs
58
+ - [ ] Secure key management
59
+
60
+ Code Security:
61
+
62
+ - [ ] No eval() or dangerous functions
63
+ - [ ] Parameterized queries (no string concat)
64
+ - [ ] Secure random number generation
65
+ - [ ] Dependency vulnerability scanning
@@ -0,0 +1,84 @@
1
+ # SQL Optimization
2
+
3
+ ## Overview
4
+ Optimize SQL queries for performance through proper indexing, query structure, and execution plan analysis. Focus on reducing query time, minimizing resource usage, and scaling efficiently.
5
+
6
+ ## Do's ✅
7
+
8
+ ### Use Indexes Effectively
9
+ ```sql
10
+ -- ✅ Good: Index on WHERE clause columns
11
+ CREATE INDEX idx_users_email ON users(email);
12
+ SELECT * FROM users WHERE email = 'user@example.com';
13
+
14
+ -- ✅ Good: Composite index for multi-column queries
15
+ CREATE INDEX idx_orders_user_date ON orders(user_id, created_at);
16
+ SELECT * FROM orders WHERE user_id = 123 AND created_at > '2024-01-01';
17
+ ```
18
+
19
+ ### Use EXPLAIN to Analyze
20
+ ```sql
21
+ -- ✅ Always check execution plan
22
+ EXPLAIN ANALYZE
23
+ SELECT * FROM orders o
24
+ JOIN users u ON o.user_id = u.id
25
+ WHERE o.created_at > '2024-01-01';
26
+ ```
27
+
28
+ ### Limit Result Sets
29
+ ```sql
30
+ -- ✅ Good: Use LIMIT for pagination
31
+ SELECT * FROM products
32
+ ORDER BY created_at DESC
33
+ LIMIT 20 OFFSET 40;
34
+
35
+ -- ✅ Good: Use EXISTS instead of COUNT
36
+ SELECT EXISTS(SELECT 1 FROM users WHERE email = 'test@example.com');
37
+ ```
38
+
39
+ ## Don'ts ❌
40
+
41
+ ### N+1 Query Problem
42
+ ```sql
43
+ -- ❌ Bad: N+1 queries
44
+ for each user:
45
+ SELECT * FROM orders WHERE user_id = user.id;
46
+
47
+ -- ✅ Good: Single JOIN query
48
+ SELECT u.*, o.*
49
+ FROM users u
50
+ LEFT JOIN orders o ON u.id = o.user_id;
51
+ ```
52
+
53
+ ### SELECT *
54
+ ```sql
55
+ -- ❌ Bad: Fetching unnecessary columns
56
+ SELECT * FROM users;
57
+
58
+ -- ✅ Good: Select only needed columns
59
+ SELECT id, email, name FROM users;
60
+ ```
61
+
62
+ ### Function on Indexed Column
63
+ ```sql
64
+ -- ❌ Bad: Function prevents index usage
65
+ SELECT * FROM users WHERE LOWER(email) = 'test@example.com';
66
+
67
+ -- ✅ Good: Function index or direct comparison
68
+ CREATE INDEX idx_users_email_lower ON users(LOWER(email));
69
+ -- OR store email in lowercase
70
+ SELECT * FROM users WHERE email = 'test@example.com';
71
+ ```
72
+
73
+ ## Best Practices
74
+
75
+ 1. **Index foreign keys** used in JOINs
76
+ 2. **Use connection pooling** to reduce overhead
77
+ 3. **Batch operations** instead of row-by-row
78
+ 4. **Monitor slow queries** with database logs
79
+ 5. **Use appropriate data types** (INT vs BIGINT)
80
+
81
+ ## Resources
82
+ - [PostgreSQL Performance Tips](https://wiki.postgresql.org/wiki/Performance_Optimization)
83
+ - [MySQL Optimization](https://dev.mysql.com/doc/refman/8.0/en/optimization.html)
84
+ - [Use The Index, Luke](https://use-the-index-luke.com/)
@@ -0,0 +1,96 @@
1
+ # State Management
2
+
3
+ Manage application state effectively using appropriate patterns and tools.
4
+
5
+ ## State Classification
6
+
7
+ ### 1. Local State
8
+ - Component-specific state (form inputs, UI toggles)
9
+ - Use: useState, useReducer
10
+ - Keep state close to where it's used
11
+
12
+ ### 2. Shared State
13
+ - State shared between multiple components
14
+ - Use: Context API for theme, auth, locale
15
+ - Avoid Context for frequently changing values (causes re-renders)
16
+
17
+ ### 3. Server State
18
+ - Data fetched from APIs
19
+ - Use: React Query, SWR, or Apollo Client
20
+ - Benefits: caching, background updates, optimistic UI
21
+ - Don't store server data in global state
22
+
23
+ ### 4. Global Application State
24
+ - Complex state shared across the app
25
+ - Use: Redux Toolkit, Zustand, Jotai, or Recoil
26
+ - Examples: shopping cart, user preferences, app config
27
+
28
+ ## Choosing the Right Tool
29
+
30
+ | State Type | Tool | Use Case |
31
+ |------------|------|----------|
32
+ | Local UI | useState | Form inputs, modals, dropdowns |
33
+ | Computed | useMemo | Derived values, expensive calculations |
34
+ | Shared Simple | Context | Theme, auth status, locale |
35
+ | Server Data | React Query/SWR | API data, caching, refetching |
36
+ | Global Complex | Redux/Zustand | Cart, multi-step forms, app-wide config |
37
+
38
+ ## Best Practices
39
+
40
+ ### State Placement
41
+ - Keep state as local as possible
42
+ - Lift state up only when necessary
43
+ - Avoid prop drilling (use Context or state management library)
44
+ - Co-locate state with components that use it
45
+
46
+ ### State Updates
47
+ - Never mutate state directly (use immutable updates)
48
+ - Use functional updates for state that depends on previous value
49
+ - Batch related state updates
50
+ - Avoid excessive state splitting (group related state)
51
+
52
+ ### Performance
53
+ - Memoize expensive computations (useMemo)
54
+ - Memoize callbacks (useCallback)
55
+ - Use state selectors to prevent unnecessary re-renders
56
+ - Split contexts to avoid re-rendering unrelated components
57
+
58
+ ### Context API Guidelines
59
+ - Create separate contexts for separate concerns
60
+ - Don't put frequently changing values in Context (causes re-renders)
61
+ - Use Context for truly global, infrequently changing data
62
+ - Consider useMemo for context values
63
+
64
+ ### Redux Toolkit Guidelines
65
+ - Use createSlice for reducers
66
+ - Use createAsyncThunk for async actions
67
+ - Use selectors with reselect for derived data
68
+ - Normalize complex nested state
69
+ - Keep business logic in reducers, not components
70
+
71
+ ### React Query/SWR Guidelines
72
+ - Set appropriate staleTime and cacheTime
73
+ - Use queryKey properly (includes dependencies)
74
+ - Implement optimistic updates for better UX
75
+ - Handle loading and error states
76
+ - Use mutations for POST/PUT/DELETE
77
+
78
+ ## Anti-Patterns to Avoid
79
+
80
+ ❌ Storing server data in Redux (use React Query instead)
81
+ ❌ Putting everything in global state
82
+ ❌ Mutating state directly
83
+ ❌ Using Context for high-frequency updates
84
+ ❌ Over-fetching data (fetch only what you need)
85
+ ❌ Ignoring loading and error states
86
+ ❌ Complex state logic in components (move to reducers/hooks)
87
+
88
+ ## Quick Checklist
89
+
90
+ - [ ] State is placed at appropriate level (local vs shared)
91
+ - [ ] Using correct tool for state type
92
+ - [ ] Server state managed by React Query/SWR
93
+ - [ ] State updates are immutable
94
+ - [ ] Performance optimizations applied (memoization, selectors)
95
+ - [ ] Loading and error states handled
96
+ - [ ] No prop drilling (use Context or state library)
@@ -0,0 +1,65 @@
1
+ # Task Planning Ability
2
+
3
+ Break down complex projects into manageable tasks.
4
+
5
+ ## Planning Process
6
+
7
+ 1. **Understand** the goal
8
+ - Clarify requirements
9
+ - Identify constraints
10
+ - Define success criteria
11
+
12
+ 2. **Decompose** into tasks
13
+ - Break into phases
14
+ - Identify dependencies
15
+ - Estimate effort
16
+ - Prioritize
17
+
18
+ 3. **Create** actionable steps
19
+ - Each task should be:
20
+ - Specific and clear
21
+ - Measurable
22
+ - Achievable
23
+ - Time-bound
24
+
25
+ 4. **Review** and adjust
26
+ - Check for gaps
27
+ - Validate estimates
28
+ - Get stakeholder approval
29
+ - Adjust as needed
30
+
31
+ ## Task Template
32
+
33
+ ```
34
+ Task: [Clear, action-oriented title]
35
+
36
+ Description:
37
+ - What needs to be done
38
+ - Why it's important
39
+ - Expected outcome
40
+
41
+ Acceptance Criteria:
42
+ - [ ] Criterion 1
43
+ - [ ] Criterion 2
44
+ - [ ] Criterion 3
45
+
46
+ Estimate: [time estimate]
47
+ Priority: [High/Medium/Low]
48
+ Dependencies: [other tasks]
49
+ ```
50
+
51
+ ## Prioritization Framework
52
+
53
+ **Eisenhower Matrix:**
54
+
55
+ 1. Urgent + Important: Do first
56
+ 2. Important + Not urgent: Schedule
57
+ 3. Urgent + Not important: Delegate
58
+ 4. Neither: Eliminate
59
+
60
+ **Value vs Effort:**
61
+
62
+ - High value, low effort: Quick wins
63
+ - High value, high effort: Major projects
64
+ - Low value, low effort: Fill-ins
65
+ - Low value, high effort: Avoid