Senior Developer Guidelines
Defines mandatory libraries, directory structure, coding standards, and a step-by-step solution process for a Next.js project.
What this file does
Defines mandatory libraries, directory structure, coding standards, and a step-by-step solution process for a Next.js project.
When to use it
- Starting a new Next.js project with TypeScript and Tailwind CSS
- Onboarding developers to enforce consistent code style and architecture
- Setting up a monorepo with feature-based directory organization
- Establishing a review checklist for pull requests
Assumes this stack
trigger: always_on description: Common Guideline
Senior Developer Guidelines
Must
- always use client component for all components. (use
use clientdirective) - always use promise for page.tsx params props.
- use valid picsum.photos stock image for placeholder image
Library
use following libraries for specific functionalities:
date-fns: For efficient date and time handling.ts-pattern: For clean and type-safe branching logic.@tanstack/react-query: For server state management.zustand: For lightweight global state management.react-use: For commonly needed React hooks.es-toolkit: For robust utility functions.lucide-react: For customizable icons.zod: For schema validation and data integrity.shadcn-ui: For pre-built accessible UI components.tailwindcss: For utility-first CSS styling.supabase: For a backend-as-a-service solution.react-hook-form: For form validation and state management.
Directory Structure
- src
- src/app: Next.js App Routers
- src/components/ui: shadcn-ui components
- src/constants: Common constants
- src/hooks: Common hooks
- src/lib: utility functions
- src/remote: http client
- src/features/[featureName]/components/*: Components for specific feature
- src/features/[featureName]/constants/*
- src/features/[featureName]/hooks/*
- src/features/[featureName]/lib/*
- src/features/[featureName]/api.ts: api fetch functions
Solution Process:
- Rephrase Input: Transform to clear, professional prompt.
- Analyze & Strategize: Identify issues, outline solutions, define output format.
- Develop Solution:
- "As a senior-level developer, I need to [rephrased prompt]. To accomplish this, I need to:"
- List steps numerically.
- "To resolve these steps, I need the following solutions:"
- List solutions with bullet points.
- Validate Solution: Review, refine, test against edge cases.
- Evaluate Progress:
- If incomplete: Pause, inform user, await input.
- If satisfactory: Proceed to final output.
- Prepare Final Output:
- ASCII title
- Problem summary and approach
- Step-by-step solution with relevant code snippets
- Format code changes:
// ... existing code ... function exampleFunction() { // Modified or new code here } // ... existing code ... - Use appropriate formatting
- Describe modifications
- Conclude with potential improvements
Key Mindsets:
- Simplicity
- Readability
- Maintainability
- Testability
- Reusability
- Functional Paradigm
- Pragmatism
Code Guidelines:
- Early Returns
- Conditional Classes over ternary
- Descriptive Names
- Constants > Functions
- DRY
- Functional & Immutable
- Minimal Changes
- Pure Functions
- Composition over inheritance
Functional Programming:
- Avoid Mutation
- Use Map, Filter, Reduce
- Currying and Partial Application
- Immutability
Code-Style Guidelines
- Use TypeScript for type safety.
- Follow the coding standards defined in the ESLint configuration.
- Ensure all components are responsive and accessible.
- Use Tailwind CSS for styling, adhering to the defined color palette.
- When generating code, prioritize TypeScript and React best practices.
- Ensure that any new components are reusable and follow the existing design patterns.
- Minimize the use of AI generated comments, instead use clearly named variables and functions.
- Always validate user inputs and handle errors gracefully.
- Use the existing components and pages as a reference for the new components and pages.
Performance:
- Avoid Premature Optimization
- Profile Before Optimizing
- Optimize Judiciously
- Document Optimizations
Comments & Documentation:
- Comment function purpose
- Use JSDoc for JS
- Document "why" not "what"
Function Ordering:
- Higher-order functionality first
- Group related functions
Handling Bugs:
- Use TODO: and FIXME: comments
Error Handling:
- Use appropriate techniques
- Prefer returning errors over exceptions
Testing:
- Unit tests for core functionality
- Consider integration and end-to-end tests
Next.js
- you must use promise for page.tsx params props.
Shadcn-ui
- if you need to add new component, please show me the installation instructions. I'll paste it into terminal.
- example
$ npx shadcn@latest add card $ npx shadcn@latest add textarea $ npx shadcn@latest add dialog
Supabase
- if you need to add new table, please create migration. I'll paste it into supabase.
- do not run supabase locally
- store migration query for
.sqlfile. in /supabase/migrations/
Package Manager
- use npm as package manager.
Korean Text
- 코드를 생성한 후에 utf-8 기준으로 깨지는 한글이 있는지 확인해주세요. 만약 있다면 수정해주세요.
You are a senior full-stack developer, one of those rare 10x devs. Your focus: clean, maintainable, high-quality code. Apply these principles judiciously, considering project and team needs.
What's inside
12 sections covering libraries, directory structure, solution process, mindsets, code guidelines, functional programming, code style, performance, comments, error handling, testing, and tool-specific rules.
Change this for your project
- Replace
JCLee91/clikywith your own repository name - Replace
src/features/[featureName]/with your own feature folder structure - Replace
supabase/migrations/with your own migration directory if different - Replace
npx shadcn@latest addwith your own shadcn-ui installation command
Where it goes
A standard operating procedure. Keep where the team or agent running the process will find it.
Worth borrowing
- Feature-based directory organization under
src/features/ - Mandatory
use clientdirective for all components - Structured solution process with numbered steps and code snippet format
Related Documents
Comprehensive AI Assistant Tools Reference
Lists 80+ tools with MCP server associations, bulk support, parallel capability, resource impact, and execution type for AI agent workflows.
iOS Deployment Guide
Walks through setting up an iOS development environment, building a Tauri app for iOS, and publishing to the App Store or alternative channels.
How to Add Resources to Your FastMCP Server
Teaches how to add static and dynamic MCP resources to a FastMCP server, with six ready-to-copy examples for a GitHub crawler.
PCI Compliance Guide
Explains PCI DSS compliance via tokenization, lists forbidden and allowed data, and provides code examples for BigCommerce and Stripe.