一键导入
laravel-debugging-prompts
Create effective debugging prompts—include error messages, stack traces, expected vs actual behavior, logs, and attempted solutions
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create effective debugging prompts—include error messages, stack traces, expected vs actual behavior, logs, and attempted solutions
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Build AI features with the first-party Laravel AI SDK (Laravel 13+); agents, embeddings, images, audio, and tool calling with provider-agnostic APIs
Use API Resources with pagination and conditional fields; keep response shapes stable and cache-friendly
Compose UIs with Blade components, slots, and layouts; keep templates pure and testable
Request effective code reviews—specify focus areas, provide context, ask for architectural feedback, reference Laravel conventions
Practical daily checklist for Laravel projects; bring services up, run migrations, queues, quality gates, and tests
Provide comprehensive context in prompts—files, errors, Laravel version, dependencies, and monorepo details—for accurate AI responses
| name | laravel:debugging-prompts |
| description | Create effective debugging prompts—include error messages, stack traces, expected vs actual behavior, logs, and attempted solutions |
Debugging with AI requires complete information. Missing context means generic suggestions that don't solve your specific problem.
"Getting an error in the payment controller"
"Getting error when processing payment:
Error:
Illuminate\Database\QueryException: SQLSTATE[23000]:
Integrity constraint violation: 1452 Cannot add or update a child row:
a foreign key constraint fails (`app`.`payments`, CONSTRAINT `payments_order_id_foreign`
FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE)
Stack trace:
#0 app/Services/PaymentService.php(45): Payment::create()
#1 app/Http/Controllers/PaymentController.php(28): PaymentService->process()
#2 vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54)
Context:
['order_id' => 999, 'amount' => 5000, 'status' => 'pending']Why it works: Complete error, stack trace, context, and the specific data causing the issue.
"The API isn't returning the right data"
"Product API returning incorrect data:
Expected behavior:
{
"data": {
"id": 1,
"name": "Widget",
"price": "29.99",
"category": {
"id": 5,
"name": "Tools"
}
}
}
Actual behavior:
{
"data": {
"id": 1,
"name": "Widget",
"price": 2999,
"category": null
}
}
Issues:
Code:
// ProductController@show
return new ProductResource($product);
Product has category_id = 5 in database, but relationship not loading."
Why it works: Shows exact expected vs actual output, identifies specific issues, includes relevant code.
"Something's wrong with the queue"
"Job failing in queue:
Log entries:
[2024-01-15 10:30:15] local.ERROR: Job failed: ProcessOrderJob
{"order_id":123,"exception":"Stripe\\Exception\\InvalidRequestException:
No such customer: cus_invalid","attempts":3}
[2024-01-15 10:30:15] local.INFO: Order state before job
{"id":123,"status":"pending","stripe_customer_id":"cus_invalid"}
Job code:
public function handle()
{
$customer = $this->stripe->customers->retrieve(
$this->order->stripe_customer_id
);
// ...
}
State:
stripe_customer_id = "cus_invalid"Why it works: Includes logs, state information, relevant code, and context about retries.
"I think it's a caching issue"
"Suspect Redis cache is stale:
Hypothesis: Product prices are cached but not invalidating on update.
Evidence:
UPDATE products SET price = 3999 WHERE id = 1SELECT price FROM products WHERE id = 1 → 3999GET /api/products/1 → "price": "29.99"php artisan cache:clear, API returns correct price: "price": "39.99"Caching code:
public function show(Product $product)
{
$cached = Cache::remember("product.{$product->id}", 3600, function () use ($product) {
return new ProductResource($product);
});
return $cached;
}
Problem: Cache key doesn't invalidate when product updates. Need cache invalidation in ProductObserver or remove caching from show method."
Why it works: Clear hypothesis, concrete evidence, relevant code, proposed solution.
"I tried some things but nothing worked"
"Attempted solutions and results:
Attempt 1: Added eager loading
$products = Product::with('category')->get();
Result: Still getting N+1 queries. Debugbar shows 101 queries (1 for products, 100 for categories).
Attempt 2: Used load() after fetching
$products = Product::all();
$products->load('category');
Result: Same issue, still 101 queries.
Attempt 3: Checked relationship definition
// In Product model
public function category()
{
return $this->belongsTo(Category::class);
}
Result: Relationship looks correct. Foreign key category_id exists in products table.
Current state: Eager loading syntax seems correct but not working. Using Laravel 13.x. What am I missing?"
Why it works: Shows what was tried, exact code used, results observed, helps avoid suggesting already-tried solutions.
**Error:** [Full error message]
**Stack trace:** [Complete stack trace]
**File/Line:** [Where error occurs]
**Context:** [Laravel version, packages, environment]
**Data:** [Input data causing error]
**Expected:** [What should happen]
**Expected:** [Describe expected behavior with example]
**Actual:** [Describe actual behavior with example]
**Code:** [Relevant code snippet]
**State:** [Database state, variable values]
**Environment:** [Laravel version, Sail/host, packages]
**Problem:** [Describe slow operation]
**Metrics:** [Response time, query count, memory usage]
**Query log:** [Slow queries from Debugbar/Telescope]
**Code:** [Code causing performance issue]
**Dataset size:** [Number of records involved]
**Attempted:** [Optimizations already tried]
Debug effectively with AI:
More information = faster solutions. When debugging, over-communicate.