0. Keep docker running in separate outside of VSCODE terminal
1. The importance of GIT for version control - create modernization branch
2. Add rules:
Prefer simple solutions
Only make requested changes, that are well understood and related to the request
Think about what other methods and areas of code that might be affected by code changes
Always look for existing code to iterate instead of creating new code
Avoid
code duplication, which means checking for other areas of the codebase
that might already have similar code and functionality
Do no touch code that is unrelated to the task
Focus on the code areas that are relevant to the task
Keep the codebase clean and organized
Generate
code for specific, defined transformations (e.g., adding namespace to
one file, updating callers for one file), do not to perform project-wide
automated changes
3. Have two different chats: for fixes, and enhancements
1. Refactoring:
Start refactoring with Cursor using agents as it reads best context: use thinking model for understanding better the prompt and deep code relations.
Initial prompt: Analyze the include and require statements in /src. Suggest and create a PSR-4 namespace structure (e.g., App\), move, update and refactor the existing files based on the new structure. @src
Context: If the project is large instead of providing the entire src directory, provide more specific context (e.g., @src/Models or: @UserModel.php @Database.php) when the task is focused on a particular area.
2. Fixes:
Prompt 1: could you fix the following: Keep in mind that the project path: /var/www/html(inside docker) points to location: /real_path/src
Prompt:2 I am receiving the following warnings, could you try to fix them: add as context the whole directory @src
(repeat multiple times until the code is running)
If there is persistant bug / error. Use the gemini code extension, but carefully provide context of related files!
Remember: On success save in git and then continue && Don't overflow the chat buffer, start new chat.
Second prompt: Could you suggest an optimization of the PHP class structure that
could encapsulate the logic and data handled in this code. Please use
PDO and make it compatible with the rest of the code.
3. Advanced prompts:
3.1. Refactor the PHP code to improve readability and maintainability. Consider breaking down long functions, using modern PHP syntax (e.g., PHP 7.x/8.x features like null coalesce operator, short array 3.2. Look at the application as a whole and tell if
there are architectural patters that can be used to improve the project.syntax, type hints if applicable), and adhering to PSR-12 coding standards.
4. Security
Analyze this PHP code snippet for common security vulnerabilities like SQL Injection, Cross-Site Scripting (XSS), and insecure variable handling. Suggest safer alternatives using modern practices (e.g., prepared statements, output escaping). Add rate limiting if possible.