Look up current best practices for a technology, pattern, or implementation approach with recommendations
Researches current best practices for any technology, pattern, or implementation approach with context-specific recommendations.
/plugin marketplace add C0ntr0lledCha0s/claude-code-plugin-automations/plugin install research-agent@claude-code-plugin-automations[technology/pattern/topic]Quickly look up current best practices (as of 2025) for any technology, design pattern, or implementation approach, with context-specific recommendations.
$ARGUMENTS: The technology, pattern, or topic to research best practices for (e.g., "React hooks", "API error handling", "database indexing")When this command is invoked with /best-practice <topic>:
/best-practice React hooks 2025
Expected behavior:
Checks for existing hooks usage in project
Researches current React hooks best practices:
Provides comprehensive guide:
Best Practices for React Hooks (2025)
// ✓ Good: Descriptive names, appropriate initial values
const [isLoading, setIsLoading] = useState(false);
const [user, setUser] = useState<User | null>(null);
// ✗ Avoid: Storing derived state
const [fullName, setFullName] = useState(''); // Derive instead!
const fullName = `${firstName} ${lastName}`; // Better
// ✓ Good: Cleanup functions, specific dependencies
useEffect(() => {
const controller = new AbortController();
fetchData(controller.signal);
return () => controller.abort(); // Cleanup
}, [specificDep]); // Precise dependencies
// ✗ Avoid: Missing dependencies
useEffect(() => {
doSomething(prop); // 'prop' not in deps!
}, []); // ESLint will catch this
// ✓ Good: Reusable, focused, well-named
function useFetch<T>(url: string) {
const [data, setData] = useState<T | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
useEffect(() => {
// Fetch logic with proper cleanup
}, [url]);
return { data, loading, error };
}
Sources:
/best-practice API authentication security
Expected behavior:
Checks current auth implementation in project
Researches security best practices:
Provides security-focused guide:
API Authentication Security Best Practices (2025)
// ✓ Good: Secure JWT implementation
const token = jwt.sign(payload, SECRET, {
expiresIn: '15m', // Short-lived
algorithm: 'RS256' // Asymmetric encryption
});
// Set in HttpOnly cookie (not localStorage!)
res.cookie('token', token, {
httpOnly: true, // Prevents XSS
secure: true, // HTTPS only
sameSite: 'strict', // CSRF protection
maxAge: 900000 // 15 minutes
});
Sources:
/best-practice Next.js project structure
Expected behavior:
Checks current project structure
Researches Next.js official recommendations
Provides structure guide:
Next.js Project Structure Best Practices (2025)
/app # App Router directory
/(routes) # Route groups (optional)
/(marketing)
/about
/pricing
/(dashboard)
/settings
/profile
/api # API routes
/components
/ui # Reusable UI components
/features # Feature-specific components
/lib # Utilities, helpers
/api # API client functions
/utils # Pure utility functions
/hooks # Custom React hooks
/types # TypeScript type definitions
/styles # Global styles
/public # Static assets
/config # Configuration files
/tests # Test files
page.tsx, layout.tsx, loading.tsx, error.tsxPascalCase.tsxcamelCase.tsPascalCase.ts or types.ts// Feature-based grouping (preferred for scale)
/components
/auth
/LoginForm
LoginForm.tsx
LoginForm.test.tsx
LoginForm.styles.ts
/dashboard
/StatsCard
StatsCard.tsx
Sources:
/best-practice PostgreSQL indexing
Expected behavior:
Researches database indexing best practices
Provides practical guide:
PostgreSQL Indexing Best Practices (2025)
-- B-tree (default, most common)
CREATE INDEX idx_users_email ON users(email);
-- Unique index (enforce uniqueness)
CREATE UNIQUE INDEX idx_users_username ON users(username);
-- Partial index (conditional, saves space)
CREATE INDEX idx_active_users ON users(email) WHERE active = true;
-- Composite index (multiple columns, order matters!)
CREATE INDEX idx_users_name ON users(last_name, first_name);
-- GIN index (for JSON, arrays, full-text search)
CREATE INDEX idx_users_tags ON users USING GIN(tags);
-- GiST index (for geometric data, full-text)
CREATE INDEX idx_locations ON places USING GIST(location);
Monitoring:
-- Check index usage
SELECT schemaname, tablename, indexname, idx_scan
FROM pg_stat_user_indexes
ORDER BY idx_scan;
-- Find unused indexes
SELECT * FROM pg_stat_user_indexes WHERE idx_scan = 0;
Sources:
# Best Practices: [Topic]
## Current Implementation (if applicable)
[Analysis of how it's currently done in the project]
- Files: `path/to/file.ts:42`
- Assessment: [Brief evaluation]
## Current Best Practices (2025)
### Core Principles
1. [Principle 1]
2. [Principle 2]
3. [Principle 3]
### Recommended Approach
[Detailed explanation of best approach]
```[language]
// Code example showing best practice
[Pitfall]: [Why it's problematic]
[Pitfall]: [Why it's problematic]
| Aspect | Current | Best Practice |
|---|---|---|
| ... | ... | ... |
[Condensed summary of key points for quick lookup]
## Important Notes
- Always research **current** practices (2025, not outdated info)
- Cite authoritative sources (official docs, standards bodies)
- Provide context-specific advice, not generic platitudes
- Include code examples in the relevant language/framework
- Balance ideals with pragmatism
- Note trade-offs explicitly
- Consider project constraints and team skills
## Error Handling
### If no topic provided:
Error: No topic specified.
Usage: /best-practice <topic>
Examples: /best-practice React hooks /best-practice API error handling /best-practice git workflow /best-practice TypeScript error types
### If topic is too broad:
Provide overview and ask for specifics:
Best Practices: [Broad Topic]
This is a broad topic. Here's an overview of subtopics:
For more specific guidance, try: /best-practice [Broad Topic] [Subtopic]
Or I can provide a general overview of all best practices in this area?
## Advanced Usage
### Compare with current implementation:
/best-practice error handling in src/api
Focuses on error handling specifically in the API layer.
### Technology-specific:
/best-practice Next.js 15 data fetching
Gets practices for specific version.
### Security-focused:
/best-practice secure file upload
Emphasizes security aspects.
---
**Pro Tip**: Use /best-practice to learn current standards, then /investigate to see how your project compares, then /research for deeper dive into specific approaches.