home/coding/generate-feature

Generate Feature

GPTClaudeDeepSeek··1,206 copies·updated 2026-07-14
generate-feature.prompt
# Prompt: Generate Feature

Copy this template into Cursor Chat or Agent. Replace placeholders in `ALL_CAPS`.

---

## Context

You are implementing a feature in a Laravel API using layered architecture:

**Controller → Service → Repository → Model**

Follow project rules in `.cursor/rules/` and documentation:

- @docs/architecture.md
- @docs/business-rules.md
- @docs/coding-standards.md

Reference implementation style: @examples/laravel/

## Feature

**Name:** `FEATURE_NAME`

**Description:**  
`SHORT_DESCRIPTION_OF_WHAT_WE_ARE_BUILDING`

**Business rules to implement:**  
`BR-001, BR-002, ...` (copy from docs)

**API endpoints:**

| Method | Path | Action |
|--------|------|--------|
| `METHOD` | `/api/PATH` | `DESCRIPTION` |

## Constraints

- PHP 8.2+, `declare(strict_types=1);`
- No business logic in controllers
- Services throw domain exceptions; map to HTTP in handler
- Repository behind interface + service provider binding
- Use DTOs between controller and service
- Form Requests for validation with `toDto()` method
- API Resources for responses

## Task

Implement the feature in this order:

1. Migration and Model (if new entity)
2. DTO(s)
3. `Contracts/Repositories/*Interface`
4. `Repositories/Eloquent*Repository`
5. `Services/*Service` with business rules
6. Domain exceptions as needed
7. Form Requests + API Resources
8. Controller + route registration snippet
9. Service provider binding

## Output format

- List each new/changed file path
- Provide full file contents (no ellipsis)
- End with a short "manual steps" list (e.g. run migration, register routes)

## Do not

- Add packages without stating why
- Use facades inside services for testable code paths
- Skip interface for repository

---

## Example (filled)

**Name:** Product — Create endpoint

**Description:** Allow authenticated users to create a product with name, sku, price, stock.

**Business rules:** BR-001 through BR-006

**API:** `POST /api/products`

**Task:** Implement steps 1–9 for create only; include `StoreProductRequest` and `CreateProductDTO`.

when to use it

Community prompt sourced from the open-source GitHub repo YoungC0DE/cursor-ai-template (MIT). A "Generate Feature" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

codingcommunitydeveloper

source

YoungC0DE/cursor-ai-template · MIT