code-a2z
Copilot instructions148 starsChanged 13 months agoMITView on GitHub
Code A2Z is a collaborative blogging platform built as a monorepo with separate client and server applications. Contributors can create, manage, and share blog posts about their projects with markdown support, customizable templates, and role-based access control. Each feature module follows this pattern:
- Reads credentials
We split this copilot-instructions.md into the rules it gives an agent
52 rules. About 1 is common, 35 are distinctive, and 16 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈35
Distinctive · estimate
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 148
Use functional components with hooks
- Distinctive: line 150
Use TypeScript interfaces for props
- Very specific: line 151
Follow Atomic Design pattern in shared/components
- Very specific: line 177
Always use sendResponse utility for responses
- Distinctive: line 178
Add JSDoc comments for API endpoints
- Distinctive: line 202
Use Jotai atoms for state management
- Very specific: line 204
Keep atoms in module-specific states/ directory or infra/states/ for global state
- Distinctive: line 217
Use Mongoose models for data persistence
- Distinctive: line 218
Keep schemas separate from models
- Distinctive: line 219
Use constants for collection names
- Very specific: line 225
Use Axios with interceptors in shared/utils/api-interceptor.ts
- Very specific: line 232
Use authenticateUser middleware for protected routes
- Distinctive: line 251
Use Material-UI components as base
- Distinctive: line 253
Keep consistent spacing and color schemes from MUI theme
- Distinctive: line 254
Avoid utility-based CSS frameworks (no Tailwind, Bootstrap, etc.)
- Distinctive: line 260
Use try-catch blocks for async operations
- Very specific: line 266
Use sendResponse utility for consistent error responses
- Common: line 268
Use middleware for error handling
- Very specific: line 276
Use sanitize-html for HTML content
- Distinctive: line 278
Use Helmet for security headers
- Distinctive: line 279
Use HPP to prevent HTTP parameter pollution
- Distinctive: line 281
Use JWT for authentication (httpOnly cookies)
- Distinctive: line 290
Use virtual properties for computed fields
- Distinctive: line 291
Keep schemas in separate files from models
- Very specific: line 311
Run npm run lint to check, npm run lint:fix to auto-fix
- Very specific: line 322
Run npm run format to format all files
- Distinctive: line 327
Never commit directly to main branch
- Distinctive: line 328
Create feature branches with descriptive names
- Distinctive: line 329
Keep commits focused (3-4 commits max per PR)
- Distinctive: line 330
Write clear commit messages
- Distinctive: line 337
When adding tests, place them near the code they test
- Very specific: line 338
Use .test.ts or .test.js extensions
- Distinctive: line 339
Follow existing project structure patterns
- Distinctive: line 343
Add JSDoc comments for complex functions
- Distinctive: line 344
Document API endpoints in controller files
- Distinctive: line 345
Update README.md when adding major features
- Distinctive: line 346
Keep CONTRIBUTING.md current with workflow changes
- Distinctive: line 347
Add inline comments only when necessary for clarity
- Distinctive: line 353
Use React.memo for expensive components
- Distinctive: line 354
Use useCallback and useMemo for optimization
- Distinctive: line 361
Use database indexes for query optimization
- Distinctive: line 363
Use rate limiting to prevent abuse
- Distinctive: line 369
Before starting: Check existing issues and documentation
- Very specific: line 389
Never commit .env files
- Very specific: line 390
Document all variables in .env.example
- Distinctive: line 397
Use relative imports for local files
- Very specific: line 398
Use absolute imports from src/ root when needed
- Very specific: line 403
Use ESM syntax (import/export)
- Very specific: line 404
Use .js extension in imports (required for ESM)
- Distinctive: line 411
Type everything: - Use TypeScript interfaces and JSDoc where applicable
- Distinctive: line 412
Validate inputs: - Never trust client data on the server
- Very specific: line 422
Check existing documentation in /docs
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GitHub Copilot Instructions for Code A2Z
Project Overview
Code A2Z is a collaborative blogging platform built as a monorepo with separate client and server applications. Contributors can create, manage, and share blog posts about their projects with markdown support, customizable templates, and role-based access control.
Repository Structure
code-a2z/
├── client/ # React + TypeScript + Vite frontend
│ └── src/
│ ├── modules/ # Feature modules (home, editor, profile, etc.)
│ ├── shared/ # Shared utilities and components
│ │ ├── components/ # Atomic design pattern
│ │ │ ├── atoms/ # Basic UI elements
│ │ │ ├── molecules/ # Composite components
│ │ │ └── organisms/ # Complex sections
│ │ ├── hooks/ # Custom React hooks
│ │ ├── states/ # Jotai state atoms
│ │ └── utils/ # Helper functions
│ ├── infra/ # Infrastructure layer
│ │ ├── rest/ # API clients
│ │ ├── states/ # Global state
│ │ └── types/ # TypeScript types
│ ├── config/ # Configuration files
│ └── assets/ # Static assets
├── server/ # Node.js + Express + MongoDB backend
│ └── src/
│ ├── controllers/ # Request handlers by domain
│ ├── routes/ # API route definitions
│ ├── models/ # Mongoose models
│ ├── schemas/ # Mongoose schemas
│ ├── middlewares/ # Express middlewares
│ ├── utils/ # Helper functions
│ ├── config/ # Server configuration
│ ├── constants/ # Constant values
│ ├── logger/ # Winston logging
│ └── typings/ # Type definitions
└── docs/ # Project documentationTech Stack
Client
- Framework: React 19 with TypeScript
- Build Tool: Vite (using Rolldown)
- State Management: Jotai
- UI Library: Material-UI (MUI)
- Routing: React Router v7
- Editor: EditorJS
- Styling: Emotion CSS-in-JS
Server
- Runtime: Node.js (>=18.0.0)
- Framework: Express.js
- Database: MongoDB with Mongoose
- Authentication: JWT with bcrypt
- File Upload: Multer + Cloudinary
- Email: Nodemailer + Resend
- Security: Helmet, HPP, sanitize-html
- Rate Limiting: rate-limiter-flexible
- Logging: Winston + Morgan
Coding Standards
File Naming Conventions
Client (TypeScript/React)
- Components:
kebab-casefiles,PascalCaseexportsindex.tsx- Main component filerender-menu.tsx- Sub-componentscategory-button.tsx- Feature components
- Hooks:
kebab-casewithuse-prefixuse-auth.tsuse-editor.ts
- Utils:
kebab-case.tsapi-interceptor.tsdate.tsregex.ts
- State:
kebab-casefiles with descriptive namesauth-state.tseditor-state.ts
- Types:
kebab-case.tsuser-types.tsproject-types.ts
Server (JavaScript/Node.js)
- Controllers:
kebab-case.jswith action namesignup.jscreate-project.jsupload-image.js
- Routes:
*.routes.jsauth.routes.jsproject.routes.js
- Models:
*.model.jsuser.model.jsproject.model.js
- Schemas:
*.schema.jsuser.schema.jsproject.schema.js
- Middlewares:
*.middleware.jsor*.limiter.jsauth.middleware.jsauth.limiter.js
- Utils:
kebab-case.jsor descriptive namesresponse.jsregex.js
Code Organization
Client Module Structure
Each feature module follows this pattern:
module-name/
├── index.tsx # Main module component
├── components/ # Module-specific components
│ ├── component-name.tsx
│ └── index.tsx
├── hooks/ # Module-specific hooks
│ └── index.ts
├── states/ # Module-specific state
│ └── index.ts
└── constants/ # Module-specific constants
└── index.tsServer Domain Structure
Each domain (auth, project, user, etc.) follows this pattern:
domain/
├── controller-action.js # One controller per action
└── utils/ # Domain-specific utilities (if needed)
└── index.jsComponent Patterns
React Components
- Use functional components with hooks
- Export default for main component
- Use TypeScript interfaces for props
- Follow Atomic Design pattern in
shared/components- Atoms: Basic elements (Button, Typography, Modal)
- Molecules: Simple combinations (InputField, SearchBar)
- Organisms: Complex sections (Navbar, Sidebar, Comments)
Example:
const ComponentName = ({
prop1,
prop2,
}: {
prop1: string;
prop2: number;
}) => {
// Component logic
return <div>...</div>;
};
export default ComponentName;Server Controllers
- One function per file
- Use async/await
- Always use
sendResponseutility for responses - Add JSDoc comments for API endpoints
Example:
/**
* POST /api/auth/signup - Register a new user
* @param {string} fullname - User's full name
* @param {string} email - Valid email address
* @param {string} password - Password (6-20 chars)
* @returns {Object} User object with account details
*/
const signup = async (req, res) => {
// Controller logic
return sendResponse(res, 200, 'Success', data);
};
export default signup;State Management
Client (Jotai)
- Use Jotai atoms for state management
- Name atoms with descriptive suffixes:
*Atom,*State - Keep atoms in module-specific
states/directory orinfra/states/for global state
Example:
import { atom } from 'jotai';
export const UserAtom = atom<User | null>(null);
export const HomePageStateAtom = atom<string>('home');Server
- Use Mongoose models for data persistence
- Keep schemas separate from models
- Use constants for collection names
API Structure
Client API Calls
- Use Axios with interceptors in
shared/utils/api-interceptor.ts - Organize API functions in
infra/rest/by domain
Server Routes
- Group routes by domain in
routes/api/ - Apply rate limiters:
authLimiterfor auth,generalLimiterfor others - Use
authenticateUsermiddleware for protected routes
Example:
import express from 'express';
import authenticateUser from '../../middlewares/auth.middleware.js';
import createProject from '../../controllers/project/create-project.js';
const projectRoutes = express.Router();
projectRoutes.post('/', authenticateUser, createProject);
export default projectRoutes;Styling Guidelines
Client
- Use Material-UI components as base
- Apply Emotion for CSS-in-JS styling
- Keep consistent spacing and color schemes from MUI theme
- Avoid utility-based CSS frameworks (no Tailwind, Bootstrap, etc.)
Error Handling
Client
- Use try-catch blocks for async operations
- Display user-friendly error messages
- Log errors to console in development
Server
- Use
sendResponseutility for consistent error responses - Validate inputs before processing
- Use middleware for error handling
- Log errors using Winston logger
Security Practices
Server
- Always validate and sanitize user inputs
- Use
sanitize-htmlfor HTML content - Apply rate limiting to all routes
- Use Helmet for security headers
- Use HPP to prevent HTTP parameter pollution
- Hash passwords with bcrypt (SALT_ROUNDS constant)
- Use JWT for authentication (httpOnly cookies)
- Validate environment variables with proper typing
Database Conventions
Mongoose Models
- Use schema validation
- Define indexes for frequently queried fields
- Use virtual properties for computed fields
- Keep schemas in separate files from models
Example:
import { model } from 'mongoose';
import USER_SCHEMA from '../schemas/user.schema.js';
import { COLLECTION_NAMES } from '../constants/db.js';
const USER = model(COLLECTION_NAMES.USERS, USER_SCHEMA);
export default USER;Code Quality Tools
Linting
- ESLint configured for both client and server
- Client: TypeScript ESLint with React rules
- Server: JavaScript ESLint with Node rules
- Run
npm run lintto check,npm run lint:fixto auto-fix
Formatting
- Prettier for consistent code formatting
- Configuration in
.prettierrc:- Single quotes
- 2-space indentation
- 80 character line width
- Semicolons required
- LF line endings
- Run
npm run formatto format all files - Pre-commit hooks auto-format staged files via Husky
Git Workflow
- Never commit directly to
mainbranch - Create feature branches with descriptive names
- Keep commits focused (3-4 commits max per PR)
- Write clear commit messages
- Auto-formatting runs on commit via Husky
Testing Guidelines
While there are currently no tests in the repository:
- When adding tests, place them near the code they test
- Use
.test.tsor.test.jsextensions - Follow existing project structure patterns
Documentation
- Add JSDoc comments for complex functions
- Document API endpoints in controller files
- Update README.md when adding major features
- Keep CONTRIBUTING.md current with workflow changes
- Add inline comments only when necessary for clarity
Performance Considerations
Client
- Use React.memo for expensive components
- Use useCallback and useMemo for optimization
- Implement virtualization for long lists (react-virtuoso)
- Lazy load routes and heavy components
- Optimize images and assets
Server
- Use database indexes for query optimization
- Implement proper pagination
- Use rate limiting to prevent abuse
- Cache frequently accessed data when appropriate
- Monitor with logging middleware
Contribution Workflow
- Before starting: Check existing issues and documentation
- Create a feature branch from
main - Follow the established patterns in similar existing code
- Run linting and formatting:
npm run precommit-check - Publish a blog post about your project on the website (required for PRs)
- Add screenshots to your PR showing changes
- Fill out PR template completely
- Keep PRs focused on a single feature or fix
Environment Variables
Client
- Prefix with
VITE_ - Access via
import.meta.env.VITE_* - Define in
.env.examplewith documentation
Server
- Use
dotenvpackage - Never commit
.envfiles - Document all variables in
.env.example - Validate required variables on startup
Module Resolution
Client
- Use relative imports for local files
- Use absolute imports from
src/root when needed - Configured in
tsconfig.json
Server
- Use ESM syntax (
import/export) - Use
.jsextension in imports (required for ESM) - Relative paths for local modules
Best Practices Summary
- Follow existing patterns - Browse similar code before implementing new features
- Keep it modular - One responsibility per file/function
- Type everything - Use TypeScript interfaces and JSDoc where applicable
- Validate inputs - Never trust client data on the server
- Handle errors gracefully - Provide meaningful error messages
- Write clean code - Let linters and formatters handle style
- Document when necessary - Clear code > excessive comments
- Test your changes - Manually verify functionality before submitting
- Security first - Sanitize inputs, use HTTPS, protect sensitive data
- Be consistent - Match the style and structure of existing code
Questions or Clarifications?
- Check existing documentation in
/docs - Review similar existing implementations
- Join the Discord community for support
- Comment on relevant issues or discussions
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

