Restructuring agents.md across project directories
The user wants me to analyze the AGENTS.md file and create a plan to split it into multiple, more targeted AGENTS.md files in relevant directories. This makes sense because different parts of the codebase need different guidance.
Let me analyze the content:
About This Application - General, stays at root
Essential Commands - General developer commands, stays at root
Database Population Scripts - Database-related, could go in
db/Dev Server Logging - General, stays at root
Architecture Overview - General, stays at root
Prompt Versioning System - Related to prompts and AI, could go in
lib/services/or where prompt service livesCode Quality Principles - General, stays at root
Frontend Development - Should go in
app/andcomponents/Chrome DevTools MCP and Dev DB - Testing-related, could go in
e2e/orscripts/test-helpers/Spacing System - Frontend/styling, goes with frontend
Styling Guidelines - Frontend, goes with frontend
Copywriting Guidelines - Frontend/content, goes with frontend
Backend Development - Goes in backend-related directories
Database Rules - Goes in
db/Database Operations - Goes in
db/Migration Workflow - Goes in
db/ordrizzle/Server Actions - Goes in backend/server directories
Authentication - Goes in
lib/auth/(user is currently looking at this!)AI Integration - Goes in
lib/ai/or AI-related directoriesLogging - General, stays at root or goes in
lib/Environment Variables - General, stays at root
Git - General, stays at root
File Structure - General, stays at root
Temporary Files & Scripts - General, stays at root
Documentation Files - General, stays at root
Data Seeding & Deployment - Database-related, goes in
db/orscripts/Testing - Goes in test directories
I'll continue developing a logical plan for distributing AGENTS.md content across different project directories. The database-focused AGENTS.md will cover migration workflows, database rules, and seeding processes. This approach ensures targeted guidance for specific project areas.
I'll create a plan to split the AGENTS.md into directory-specific files. Here's my recommended structure:
Proposed Split:
1. Root /AGENTS.md (High-level overview)
- About This Application
- Essential Commands (typecheck, lint, build, test)
- Dev Server Logging
- Architecture Overview
- Code Quality Principles (DRY)
- Environment Variables
- Git conventions
- File Structure workflow
- Temporary Files & Scripts rules
- Documentation Files rules
2. /app/AGENTS.md (Frontend/UI development)
- Multi-step form patterns
- Spacing System
- Styling Guidelines (colors, error states, typography)
- Copywriting Guidelines (voice, legal translations, no emoji)
- Form components (FormRadioGroup, FormTextField, etc.)
- React Hook Form + Zod patterns
3. /components/AGENTS.md (Shared component patterns)
- Shadcn wrapper components
- Form components usage
- Callout/FormError patterns
- Component conventions
4. /db/AGENTS.md (Database-specific)
- Database Rules (snake_case, singular tables, no transactions)
- Database Operations (three-environment strategy)
- Migration Workflow
- Schema patterns
- Database Population Scripts
- Data Seeding & Deployment best practices
5. /lib/auth/AGENTS.md (Authentication)
- Server-side auth patterns
- Client-side auth patterns (useUser, SignedIn/Out)
- Middleware configuration
- Internal functions with explicit userId
6. /lib/ai/AGENTS.md (AI/LLM integration)
- AI Gateway setup and usage
- Model configuration (AVAILABLE_MODELS constants)
- Prompt Versioning System (admin UI, prompt service, DB tables)
- LLM Prompt Debugging logs
7. /lib/AGENTS.md (General utilities/services)
- Server Actions patterns
- Logging conventions
- Common utilities
8. /e2e/AGENTS.md or /scripts/test-helpers/AGENTS.md (Testing)
- Testing best practices
- Chrome DevTools MCP usage
- Clerk authentication for testing (clerk.signIn() helper)
- Standard login script
- Testing guidelines (use UI, never manual DB updates)
- Unit test patterns
- Test file organization
Does this structure make sense? Should I adjust any of the groupings or add/remove any directories?
I need to check if there's actually a /lib/auth/ directory in the codebase and what authentication-related code exists. Let me search for authentication-related files.
Yes, /lib/auth/ exists and contains access-control.ts (the file you currently have open) plus tests. However, most Clerk auth code is scattered across the codebase in server actions and services.
Recommendation: Skip creating /lib/auth/AGENTS.md since it only has one file. Instead, put authentication patterns in the root /AGENTS.md or /lib/AGENTS.md since auth code appears throughout /lib/actions/ and /lib/services/.
The user wants me to check if /lib/ai actually exists and contains AI-related code before we create an AGENTS.md file for it.
Yes, /lib/ai/ exists and contains substantial AI-related code: gateway setup, AI client, chat tools, prompts subdirectory, and mediation email generation. This is the right place for an /lib/ai/AGENTS.md file covering AI Gateway, model configuration, and prompt versioning.
The user wants me to check if /lib exists and what it contains. I already did this earlier when I listed the /lib directory, but let me check more specifically for what auth-related and general utility code exists there.
Thread
Reference Thread
T-e363aad1-62be-46e8-8b6e-f55a6d23c5b1