Embracing AI Technologies in My Coding Journey
As a firm believer in the potential of artificial intelligence, I am excited to share how AI technologies can significantly enhance productivity for both companies and individuals. In my personal projects, I often find myself creating versions of web applications, leveraging my background in Node.js, TypeScript, and various flavors of React. Each new project starts with the same desire for a solid foundation—specifically, a monorepo structure for the backend and frontend that includes the best practices and guardrails for efficient development.
Traditionally, a variety of generator tools exist to help set up this scaffolding. However, in today’s era of AI, I decided to take a different approach. I now rely on my coding agent to help build that essential foundation for me. The results, however, can be quite unpredictable. This variability inspires me to take a more hands-on role in crafting the prompts I use when interacting with different coding agents.
Crafting the Perfect Benchmark Prompt
Over time, I’ve learned that the key to getting the most out of my AI tools lies in the specificity and clarity of your prompts. I aim to design a prompt that effectively communicates my requirements for a greenfield project, preparing the coding agent to generate the desired scaffolding with precision.
Here’s what I’ve found works well in my prompt:
- Project Structure: I specify the type of project and the technologies I want integrated, such as Node.js, TypeScript, and React.
- Monorepo Setup: I highlight the need for a monorepo to keep both the backend and frontend organized under a single repository.
- Best Practices: I include requests for coding conventions and safety measures—like linters and testing frameworks—to ensure a high standard of quality from the outset.
A positive outcome for the prompt will be a base skeleton, with the correct project structure, where I can run basic commands to check the health of the code base.
Personally, in this new AI era, I found extremely helpful to setup strict guidelines and be opinionated on how you want to accept code into your code base.
The Prompt
# Task: Create a Production-Ready Node.js Monorepo
Create a complete Node.js monorepo from scratch for a full-stack web application. The monorepo should contain a backend API and frontend client with all modern development tooling configured. The result should be a working skeleton for start developing a modern web app.
## Requirements
### Project Structure
- Set up a monorepo using yarn and yarn workspaces
- Create three packages: `backend`, `frontend`, and `shared`
- Backend: Express.js API with TypeScript
- Frontend: React/Next.js application with TypeScript
- Shared: Common types, utilities, and configurations
### Development Infrastructure (Critical - This is what most agents fail at)
1. **TypeScript Configuration**
- Root tsconfig.json with project references
- Individual tsconfigs for each package
- Proper path mapping between packages
2. **Code Quality Tools**
- ESLint configuration with TypeScript support
- Prettier for code formatting
- Different lint rules for frontend (React) vs backend
3. **Git Hooks & Automation**
- Husky for git hooks
- lint-staged for pre-commit linting
- Proper commit message validation
4. **Testing Infrastructure**
- Jest configuration for both packages
- Supertest for API testing
- React Testing Library for frontend
- Coverage reporting
5. **Build & Development Scripts**
- Concurrent development servers
- Production build process
- Type checking across all packages
### Functional Requirements
- Backend: Create 3 REST endpoints (GET /health, POST /users, GET /users/:id)
- Frontend: Basic React components that call the backend API
- Shared: Common TypeScript interfaces for API contracts
- All endpoints should have proper TypeScript types
- Include basic error handling and validation
### Configuration Files Required
- package.json (root + each package)
- tsconfig.json (root + each package)
- .eslintrc.js with proper overrides
- .prettierrc
- jest.config.js (for each package)
- .husky/pre-commit hook
- .gitignore
- README.md with setup instructions
## Success Criteria
The final project should:
1. Install dependencies without errors
2. Pass all linting and type checking
3. Run concurrent dev servers with `yarn run dev`
4. Execute all tests successfully
5. Build production bundles without errors
6. Pre-commit hooks should work correctly
7. Frontend should successfully call backend API
## Bonus Points
- Docker configuration
- GitHub Actions CI/CD
- Environment variable management
- API documentation with OpenAPI/Swagger
- Database integration setup (without actual DB)