Imported from mojisejr/clurian (
AGENTS.md). Install upstream withnpx skills add mojisejr/clurian. Copyright stays with the author.
Project Overview
Project Name: Clurian - Orchard Manager
Repository: https://github.com/mojisejr/clurian
Author: mojisejr
Description: A modern web application for managing fruit orchards, tracking tree health, and maintaining activity logs. Built with Next.js 16, TypeScript, and PostgreSQL, featuring LINE Login authentication and comprehensive orchard management capabilities.
β οΈ CRITICAL SAFETY RULES
π¨ FORBIDDEN ACTIONS (NEVER ALLOWED)
- β NEVER merge PRs yourself - Provide PR link and wait for user instructions
- β ALLOWED to commit and push to staging branch - For iterative development
- β ALLOWED to create PRs to staging - After successful implementation and QA
- β NEVER work on main branch - Always use staging or feature branches
- β NEVER delete critical files (.env, .git/, node_modules/, package.json, next.config.ts, prisma/schema.prisma)
- β NEVER commit sensitive data (API keys, passwords, secrets) - Use environment variables
- β NEVER write sensitive data in GitHub issues, PRs, or commit files - This includes API keys, passwords, secrets, tokens, or any confidential information
- β NEVER skip 100% validation (build, lint, test) - Must pass completely
- β NEVER use git push --force - Only use --force-with-lease when absolutely necessary
- β NEVER implement without proper testing - Follow TDD/TDD-lite cycle
π MANDATORY TEMPORARY FILE MANAGEMENT (CRITICAL)
π¨ STRICT .TMP FOLDER POLICY (NO EXCEPTIONS)
- β NEVER use system temp directories (
/tmp/,$TEMP, etc.) - β NEVER create temporary files in project root or other folders
- β
ALWAYS create temporary files in
.tmp/folder ONLY - β
ALWAYS clean up
.tmp/folder after each operation - β
ALWAYS ensure
.tmp/folder is in.gitignore
π AUTOMATIC VERIFICATION
All operations MUST:
- Check
.tmp/folder exists before operation - Create temporary files ONLY in
.tmp/folder - Clean up
.tmp/folder immediately after use - Verify cleanup success before completion
π MANDATORY WORKFLOW RULES
- β
ALWAYS sync staging branch before any implementation:
git checkout staging && git pull origin staging - β
ALWAYS create feature branch for new work:
git checkout -b feature/[description] - β
ALWAYS ensure 100% build success before commit:
npm run build - β
ALWAYS ensure 100% lint pass before commit:
npm run lint - β
ALWAYS ensure TypeScript compilation:
npx tsc --noEmit - β
ALWAYS run tests before commit:
npm test
π― Agent-Specific Guidelines
π¨ CRITICAL: NO CODING POLICY (EXCEPT /impl COMMAND)
ABSOLUTELY NO CODE IMPLEMENTATION UNLESS EXPLICITLY TRIGGERED BY /impl COMMAND
- β NEVER write code in regular conversation
- β NEVER create or modify files without
/implcommand - β NEVER implement features in discussion mode
- β NEVER edit existing code unless
/implis used - β NEVER run build/test/lint unless part of
/implworkflow - β ALLOWED: Read, analyze, discuss, plan, explore
- β
ALLOWED: Use
/implcommand for implementation - β ALLOWED: Ask questions and provide guidance
Workflow:
- Discuss and analyze in normal mode (NO CODING)
- Wait for user to type
/impl [task] - Only then begin implementation with TDD workflow
For Code Generation Agents (ONLY during /impl)
-
Next.js App Router Patterns:
- Use
app/directory structure - API routes:
app/api/*/route.ts - Pages:
app/*/page.tsx - Layouts:
app/*/layout.tsx - Server Actions:
app/actions/or component-level
- Use
-
TypeScript Requirements:
- Strict mode enabled
- Leverage Prisma generated types
- Use proper typing for server actions
- Import domain types from
@/typesor generate from Prisma
-
React Best Practices:
- Server Components by default
- Client Components with
'use client'directive - Use Radix UI primitives for accessibility
- Follow Tailwind CSS v4 patterns
For Database/Backend Agents
-
PostgreSQL with Prisma:
- Always use Prisma Client for database operations
- Generate Prisma client after schema changes:
npx prisma generate - Run migrations:
npx prisma migrate dev - Use transactions for multi-step operations
-
Better Auth Integration:
- Auth configuration in
lib/auth.ts - LINE Login provider setup
- Session management via Better Auth
- Protected routes with middleware
- Auth configuration in
-
Server Actions:
- Export async functions from
'use server'modules - Validate inputs with Zod or similar
- Return proper error messages
- Use revalidation for cache updates
- Export async functions from
For Frontend/UI Agents
-
Component Structure:
- Reusable UI components in
components/ui/ - Feature components in appropriate subdirectories
- Use Lucide React for icons
- Follow existing naming conventions
- Reusable UI components in
-
Styling:
- Tailwind CSS v4 with CSS-in-JS
- Mobile-first responsive design
- Thai language support (Kanit font)
- Consistent color scheme (green/orange theme)
-
State Management:
- React built-in state
- Server state via Server Actions
- Form state with React hooks
- URL params for filtering/pagination
For Testing Agents
-
Vitest Framework:
- Unit tests in
tests/directory - Integration tests for API routes
- Component tests with React Testing Library
- Mock external dependencies
- Unit tests in
-
Test Organization:
- Domain logic tests:
tests/domain.test.ts - Integration tests:
tests/integration.test.ts - Feature-specific tests as needed
- Setup file:
tests/setup.ts
- Domain logic tests:
π Response Language Policy
Thai-Only Responses (MANDATORY)
- ALL responses MUST be in Thai language - ΰΉΰΈ‘ΰΉΰΈ§ΰΉΰΈ²ΰΈΰΈΉΰΉΰΉΰΈΰΉΰΈΰΈ°ΰΈΰΈ²ΰΈ‘ΰΉΰΈΰΉΰΈΰΈ ΰΈ²ΰΈ©ΰΈ²ΰΉΰΈ
- User asks in English β Respond in Thai
- User asks in Thai β Respond in Thai
- User asks in any language β Respond in Thai
- Technical terms β Keep English terms in parentheses (Next.js, TypeScript, Prisma, etc.)
ΰΈΰΈ±ΰΈ§ΰΈΰΈ’ΰΉΰΈ²ΰΈ / Examples
User (English): "How do I add a new tree to the orchard?"
Agent (Thai): "ΰΈΰΈ²ΰΈ£ΰΉΰΈΰΈ΄ΰΉΰΈ‘ΰΈΰΉΰΈΰΉΰΈ‘ΰΉΰΉΰΈ«ΰΈ‘ΰΉΰΉΰΈΰΈͺΰΈ§ΰΈ ΰΈͺΰΈ²ΰΈ‘ΰΈ²ΰΈ£ΰΈΰΈΰΈ³ΰΉΰΈΰΉΰΈΰΉΰΈ²ΰΈΰΈΰΈΰΈ£ΰΉΰΈ‘ AddTree ΰΉΰΈ components/forms/AddTree.tsx ΰΉΰΈΰΈ’..."
User (Thai): "ΰΈΰΈ°ΰΉΰΈΰΈ΄ΰΉΰΈ‘ΰΈΰΉΰΈΰΉΰΈ‘ΰΉΰΉΰΈ«ΰΈ‘ΰΉΰΈ’ΰΈ±ΰΈΰΉΰΈ?"
Agent (Thai): "ΰΈΰΈ²ΰΈ£ΰΉΰΈΰΈ΄ΰΉΰΈ‘ΰΈΰΉΰΈΰΉΰΈ‘ΰΉΰΉΰΈ«ΰΈ‘ΰΉΰΉΰΈΰΈͺΰΈ§ΰΈ ΰΈͺΰΈ²ΰΈ‘ΰΈ²ΰΈ£ΰΈΰΈΰΈ³ΰΉΰΈΰΉΰΈΰΉΰΈ²ΰΈΰΈΰΈΰΈ£ΰΉΰΈ‘ AddTree ΰΉΰΈ components/forms/AddTree.tsx ΰΉΰΈΰΈ’..."
π Agent Communication Standards
Response Quality
- Be Precise: Reference actual file names and code locations
- Show Context: Explain why specific approaches are chosen
- Provide Examples: Include code snippets when helpful
- Security First: Always consider security implications
- Agricultural Domain Awareness: Understand orchard management concepts
Code Reviews
- Check TypeScript Types: Ensure all code is properly typed
- Validate Next.js Patterns: Ensure App Router best practices
- Verify Prisma Usage: Check for proper database operations
- Test Coverage: Ensure adequate test coverage
- UI/UX Consistency: Follow existing design patterns
Task Completion
- Full Implementation: Complete all requested features
- Database Migrations: Include Prisma migrations if needed
- Testing Included: Provide tests for new code
- Documentation: Update relevant documentation
- Verification: Ensure build/lint/tests pass
ποΈ Project Context for Agents
Current Tech Stack
- Frontend: Next.js 16 + React 19 + TypeScript 5
- Styling: Tailwind CSS 4
- Database: PostgreSQL with Prisma ORM
- Authentication: Better Auth with LINE Login
- UI Components: Radix UI + Lucide React
- Testing: Vitest + React Testing Library
- PDF Generation: @react-pdf/renderer
- QR Code: qrcode library
- Deployment: Vercel (recommended)
Project Status
- β Core authentication system implemented
- β Orchard and tree management features complete
- β Activity logging system (individual and batch)
- β Dashboard with statistics and filtering
- β Follow-up tracking for sick trees
- β QR code generation for trees
- β PDF generation capabilities
- β Mobile-responsive design
- β Thai language interface
Key Files to Understand
prisma/schema.prisma- Complete database schemadocs/feature.md- Detailed feature specifications (Thai)docs/database.md- Database design documentationREADME.md- Project overview and setuppackage.json- Current dependencies and scriptslib/auth.ts- Authentication configurationapp/dashboard/page.tsx- Main dashboard implementation
Domain Models
// Core entities managed by the system
User - Orchard owners with LINE Login
Orchard - Fruit orchards with zones
Tree - Individual trees with health tracking
ActivityLog - Individual and batch activity records
π Agent Task Examples
When Asked to "Add New Feature":
// Expected pattern for Server Actions
'use server'
import { z } from 'zod'
import { prisma } from '@/lib/prisma'
const CreateTreeSchema = z.object({
orchardId: z.string().uuid(),
code: z.string().min(1),
zone: z.string(),
type: z.string(),
variety: z.string(),
})
export async function createTree(data: z.infer<typeof CreateTreeSchema>) {
try {
const validated = CreateTreeSchema.parse(data)
const tree = await prisma.tree.create({
data: validated,
})
return { success: true, tree }
} catch (error) {
return { success: false, error: error.message }
}
}
When Asked to "Create Component":
// Expected pattern for components
interface TreeCardProps {
tree: Tree & { orchard: Orchard }
onStatusChange?: (treeId: string, status: TreeStatus) => void
}
export default function TreeCard({ tree, onStatusChange }: TreeCardProps) {
return (
<div className="tree-card">
{/* Tree information display */}
{/* Status indicator */}
{/* Action buttons */}
</div>
)
}
When Asked to "Update Database":
# Always use Prisma migrations
npx prisma migrate dev --name add_new_feature
npx prisma generate # Update client types
π Quick Reference for Agents
Common Imports
// Next.js
import { NextRequest, NextResponse } from 'next/server'
import { headers, cookies } from 'next/headers'
import { redirect } from 'next/navigation'
// Database
import { prisma } from '@/lib/prisma'
import { TreeStatus, LogType } from '@prisma/client'
// Authentication
import { auth } from '@/lib/auth'
import { headers } from 'next/headers'
// UI Components
import { Button } from '@/components/ui/button'
import { Dialog } from '@/components/ui/dialog'
import { Select } from '@/components/ui/select'
// Utilities
import { clsx } from 'clsx'
import { toast } from 'react-hot-toast'
// Testing
import { render, screen } from '@testing-library/react'
import { describe, it, expect, vi } from 'vitest'
Environment Variables
DATABASE_URL=postgresql://...
BETTER_AUTH_SECRET=...
BETTER_AUTH_URL=http://localhost:3000
LINE_CHANNEL_ID=...
LINE_CHANNEL_SECRET=...
Package Scripts
{
"dev": "next dev",
"build": "prisma generate && next build",
"start": "next start",
"lint": "eslint",
"test": "vitest run"
}
Git Operations for Agents
β ALLOWED Actions
- Commit to staging: After successful implementation and QA
- Push to staging: To save progress and collaborate
- Create PRs: To staging branch for code review
Standard Workflow
# After implementation is complete
git add .
git commit -m "feat(scope): description
- What was changed
- Why it was changed
- Database migrations if any
- Tests added/updated
- QA results: βbuild βlint βtest βtypes"
# Push to staging
git push origin staging
# Optional: Create PR
gh pr create --base staging
Task Completion
- Full Implementation: Complete all requested features
- Database Changes: Include Prisma migrations
- Testing Included: Provide tests for new code
- QA Verified: Ensure build/lint/tests pass
- Committed: Push changes to staging branch
- Optional PR: Create PR if requested or for complex changes
This document provides essential context for AI agents to work effectively on the Clurian orchard management system.