chore: update AI agent guidelines and refactor prompt handling
- Added guidelines for AI agents to avoid embedding prompts in PHP and to store them in Blade files under `resources/views/prompts/`. - Updated `PostImageRegenerator` to render prompts using Blade instead of heredocs, improving maintainability and consistency with project standards. - Enhanced documentation in `CLAUDE.md` and `.cursor/rules` files to reflect these changes.
This commit is contained in:
parent
560393db2a
commit
98632404a9
5 changed files with 28 additions and 15 deletions
|
|
@ -61,3 +61,9 @@ If you hit `Illuminate\Foundation\ViteException: Unable to locate file in Vite m
|
|||
## Deployment
|
||||
|
||||
Laravel can be deployed using [Laravel Cloud](https://cloud.laravel.com/) — the fastest path to production for Laravel apps.
|
||||
|
||||
## AI agents (`app/Ai/Agents`)
|
||||
|
||||
- Do not write prompts inside agent classes (no heredocs, no long strings in `instructions()`).
|
||||
- Store prompt copy in `resources/views/prompts/**/*.blade.php` and render with `view('prompts....', $vars)->render()`.
|
||||
- Follow `PostContentStreamer`, `PostContentReviewer`, or `BrandAnalyzer` for structure.
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ This project has domain-specific skills in `.claude/skills/` (e.g. `pest-testing
|
|||
|
||||
- Follow existing code conventions. Check sibling files for structure, approach and naming before creating or editing.
|
||||
- In Vue `<DialogFooter>`, primary action button first in markup, then cancel/secondary (see `vue-typescript.mdc` and `CLAUDE.md`).
|
||||
- AI agents: prompts live in `resources/views/prompts/`; `instructions()` uses `view(...)->render()` only — never heredocs or inline prompt strings in `app/Ai/Agents/` (see `CLAUDE.md`).
|
||||
- Use descriptive names (`isRegisteredForDiscounts`, not `discount()`).
|
||||
- Reuse existing components before writing new ones.
|
||||
- Stick to existing directory structure. Do not create new base folders without approval.
|
||||
|
|
|
|||
|
|
@ -235,6 +235,12 @@ ## Dialogs
|
|||
- In `<DialogFooter>`, put the **primary action button first** in the markup, then secondary/cancel (e.g. Save → Cancel). `DialogFooter` uses `flex-col-reverse` on mobile and `sm:flex-row sm:justify-start` on desktop, so the first child is the leftmost action on larger screens.
|
||||
- Match sibling dialogs in the same feature area before inventing a new footer layout.
|
||||
|
||||
## AI agents (`app/Ai/Agents`)
|
||||
|
||||
- **Never** embed prompts in PHP (`<<<PROMPT`, heredocs, or long string literals in `instructions()`).
|
||||
- Put system/instruction text in Blade under `resources/views/prompts/` (e.g. `prompts.post_content.generator`, `prompts.post_image.regenerator`).
|
||||
- In `instructions()`, return `view('prompts....', [...])->render()` and pass only the variables the Blade file needs — same pattern as `PostContentStreamer`, `PostContentReviewer`, and `BrandAnalyzer`.
|
||||
|
||||
## Icons (@tabler/icons-vue)
|
||||
|
||||
- This project uses `@tabler/icons-vue` for all icons. NEVER use `lucide-vue-next`.
|
||||
|
|
|
|||
|
|
@ -23,21 +23,9 @@ public function __construct(
|
|||
|
||||
public function instructions(): string
|
||||
{
|
||||
$language = $this->workspace->content_language ?: 'en';
|
||||
|
||||
return <<<PROMPT
|
||||
You are editing text that will be printed inside a social media image.
|
||||
|
||||
Your job:
|
||||
- Apply the user's instruction to the current title/body/keywords.
|
||||
- Keep the same language as the input unless instruction explicitly asks to change it.
|
||||
- Fix spelling/grammar when needed.
|
||||
- Keep output concise and suitable for image overlays.
|
||||
- Preserve intent and topic; only change what's needed.
|
||||
|
||||
Return JSON only following the schema.
|
||||
Language preference: {$language}
|
||||
PROMPT;
|
||||
return view('prompts.post_image.regenerator', [
|
||||
'content_language' => $this->workspace->content_language ?: 'en',
|
||||
])->render();
|
||||
}
|
||||
|
||||
public function schema(JsonSchema $schema): array
|
||||
|
|
|
|||
12
resources/views/prompts/post_image/regenerator.blade.php
Normal file
12
resources/views/prompts/post_image/regenerator.blade.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
You are editing text that will be printed inside a social media image.
|
||||
|
||||
Your job:
|
||||
- Apply the user's instruction to the current title/body/keywords.
|
||||
- Keep the same language as the input unless the instruction explicitly asks to change it.
|
||||
- Fix spelling and grammar when needed.
|
||||
- Keep output concise and suitable for image overlays.
|
||||
- Preserve intent and topic; only change what is needed.
|
||||
|
||||
Return JSON only, following the schema.
|
||||
|
||||
Language preference: {{ $content_language ?? 'en' }}.
|
||||
Loading…
Reference in a new issue