softgala/laravel-claude-button 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

softgala/laravel-claude-button

最新稳定版本:v1.1.0

Composer 安装命令:

composer require softgala/laravel-claude-button

包简介

Adds an error copy button to Laravel 500 pages. Clipboard + VS Code integration for AI-assisted debugging.

README 文档

README

Latest Version on Packagist License

A Laravel package that adds a one-click button to your error pages. Instantly copy error details to your clipboard and optionally open the file in VS Code. Perfect for AI-assisted debugging with ChatGPT, Claude, Copilot, or any AI assistant.

Laravel AI Debug Copy Demo

Features

  • 🚀 One-Click Error Copying: Instantly copy error details to clipboard - ready to paste into any AI chat
  • 📋 Smart Clipboard: Works in HTTP contexts without HTTPS (perfect for local development)
  • 🔗 Optional VS Code Integration: Toggle to automatically open error file in VS Code
  • 💾 File Export: Saves error details to storage/app/claude-errors/latest-error.md for easy reference
  • 🎨 Clean UI: Beautiful, non-intrusive button that appears only on errors
  • 🎛️ Settings Card: Toggle VS Code auto-open on/off (preference saved in browser)
  • 🔒 Environment-Safe: Only shows in local/development environments
  • 🤖 AI-Ready Format: Clean error message + file location - perfect for any AI assistant
  • ⚙️ Zero Config: Works immediately after installation

Installation

Install the package via Composer:

composer require softgala/laravel-ai-debug-copy

The package will automatically register its service provider.

Configuration

Publish the configuration file (optional):

php artisan vendor:publish --tag=claude-button-config

This will create a config/claude-button.php file where you can customize:

return [
    // Enable or disable the button
    'enabled' => env('AI_DEBUG_BUTTON_ENABLED', true),

    // Only show in these environments
    'environments' => ['local', 'development'],

    // Stack trace depth (0 = cleanest, just error + location)
    // Set to 3+ to include stack trace for deeper debugging
    'trace_depth' => 0,
];

Note on trace_depth:

  • 0 (default): Shows only error message and file location - cleanest format for AI
  • 3+: Includes stack trace frames for additional context

Usage

Once installed, the package will automatically add a "Copy Error for AI" button to any 500 error pages in your allowed environments.

Testing

Visit the test route to see it in action:

http://your-app.test/error/test

How it Works

  1. When an error occurs, a settings card and button appear in the bottom-right corner
  2. Settings Card: Toggle "Open VS Code" on/off (preference saved in browser)
  3. Click the button to:
    • Copy error details to clipboard (works in HTTP and HTTPS)
    • Save error report to storage/app/claude-errors/latest-error.md
    • Open VS Code at the exact line where the error occurred (if enabled)
  4. Paste into your AI assistant:
    • Open ChatGPT, Claude, Copilot, or any AI chat
    • Paste (Cmd+V / Ctrl+V) - error details already in clipboard
    • Or open storage/app/claude-errors/latest-error.md and share the file
  5. Get instant AI-assisted debugging and solutions!

What Gets Copied

The button formats error information cleanly and concisely:

Test error message here

/path/to/file.php:123

That's it! Just the error message and file location. This clean format works perfectly with any AI assistant:

  • ChatGPT, Claude, Copilot, or any AI tool
  • Paste and get instant analysis
  • AI understands the file path and line number
  • No verbose formatting - straight to the point

Security

  • The button only appears in local/development environments
  • No data is sent to external servers
  • All processing happens client-side
  • VS Code opens via local vscode:// protocol

Requirements

  • PHP 8.1 or higher
  • Laravel 10.x, 11.x, or 12.x
  • VS Code (optional, for auto-opening error files)

Publishing Views

To customize the button appearance, publish the views:

php artisan vendor:publish --tag=claude-button-views

This will create resources/views/vendor/claude-button/button.blade.php.

Error Files

The package automatically saves error details to:

  • storage/app/claude-errors/latest-error.md - Always contains the most recent error
  • storage/app/claude-errors/latest-error-YYYY-MM-DD-HHMMSS.md - Timestamped backups

Old error files are automatically cleaned (keeps last 10).

Example error file:

Test error for AI debug button - This is a demo error!

/path/to/file.php:123

---

*Error captured at: 2025-10-12 14:30:45*
*Type: Exception*

These markdown files can be:

  • Opened directly in VS Code
  • Shared with any AI assistant via file upload or copy/paste
  • Committed to your repo for team debugging
  • Used for error documentation

Tips for Best Results

  1. With Any AI Assistant:

    • Click button, paste error into ChatGPT/Claude/Copilot/etc
    • Error is already formatted and ready to go
    • Get instant analysis and solutions
  2. VS Code Toggle:

    • Toggle "Open VS Code" OFF if you prefer clipboard only
    • Your preference is saved in browser localStorage
    • Perfect for quick copy without opening editor
  3. Non-HTTPS Development:

    • Works perfectly on http://localhost or any HTTP context
    • Smart clipboard fallback ensures it always works
    • No SSL certificate required
  4. Team Debugging:

    • Share the latest-error.md file with teammates
    • Everyone can paste the same error into their preferred AI tool
    • Consistent error format across team

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

Security

If you discover any security-related issues, please email contact@softgala.com instead of using the issue tracker.

Changelog

Please see CHANGELOG.md for recent changes.

License

MIT-0 (MIT No Attribution). Use it however you want, no attribution required. Please see LICENSE for more information.

Credits

Support

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT-0
  • 更新时间: 2025-10-11