Currently Available: Need a skilled Software Developer for your next project?
Categories
Laravel

Making Cursor IDE AI Agents Use Sail Instead of PHP or Composer Directly

When developing Laravel projects with Docker and Sail, it’s important that all commands use Sail to ensure the environment is consistent. However, the AI models and agents in Cursor IDE often default to running commands like php artisan or composer install directly, even when told to use Sail.

This can cause errors if the host PHP environment is missing extensions or not set up for your project.

Automatically Remind the AI Agent

To solve this, you can add shell aliases that display a message whenever php or composer are called directly. This way, when Cursor’s agent runs these commands, it will receive a clear message to use Sail or Docker instead.

Add these aliases to your shell configuration:

echo -e "\nalias php='echo \"Do not use php directly. Use sail or docker run instead.\"'\nalias composer='echo \"Do not use composer directly. Use sail or docker run instead.\"'" >> ~/.bashrc && source ~/.bashrc

Now, if Cursor’s agent tries to run php or composer, it will get this output:

Do not use php directly. Use sail or docker run instead.
What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Subscribe to my newsletter

Get new posts when I publish them.

I respect your privacy. Unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *