You are an expert prompt engineer, top notch in the world. Improve this prompt for an AI…
- User
You are an expert prompt engineer, top notch in the world. Improve this prompt for an AI agent to achieve it. Make no assumption on the nature of the tasks. Create a new branch called refacto and make the following task : first read the complete code and repo to have a good understanding of what is happening, You priority is to refactor and improve the controler logic : simple_adapter.py simple_adapter.py should be the only controller that makes the request to the backend service To this regard model_server.py has no reason to exist. Additionally there are post request that are made in front_init_repo.py. that's not a good practice, since it should be made in the controler. Also in init_repo.py there are post request that are made, it s also a bad practice, it should be made in the controller. simple_adapter.py should be the only place where communication is made (front, back) If you see fit to make other refacto, make it without braking the project. You can create new files, rename files, create folders, but be sure the dependance is updated in depending files.
- Assistant
Here's an improved prompt optimized for clarity, structure, and actionable instructions while maintaining flexibility:
Prompt:
Task: Refactor repository communication architecture to centralize all backend/frontend interactions through
simple_adapter.py.Branch: Create and work on a new branch named
refacto.Core Requirements:
-
Centralized Communication Controller
simple_adapter.pyMUST BE THE ONLY file responsible for:- Making requests to backend services
- Handling all HTTP communication (including POST requests)
- Eliminate duplicate communication logic:
- Remove
model_server.pyentirely (its functionality should be migrated/removed) - Remove all POST requests from:
front_init_repo.pyinit_repo.py
- Ensure these files no longer contain any direct communication code
- Remove
-
Structural Refactoring
- Perform the following with caution:
- Delete model_server.py (move/replace its logic into simple_adapter.py if necessary) - Update all imports/dependencies where model_server.py was referenced - Move POST request implementations from
front_init_repo.pyandinit_repo.pytosimple_adapter.py - Update all dependent files to route through the new centralized controller
- Perform the following with caution:
-
Additional Improvements (Optional but encouraged)
- Refactor related files for better:
- Code organization (create folders if needed, e.g.,
controllers/,services/) - Abstraction (e.g., create helper functions/classes for request handling)
- Error handling/retry mechanisms
- Code organization (create folders if needed, e.g.,
- Consider:
- Creating
api_client.pyfor standardized HTTP operations - Implementing request/response validation
- Improving logging for communication events
- Creating
- Refactor related files for better:
-
Critical Constraints
- Maintain full functionality - do NOT break existing workflows
- Update all imports/dependencies when renaming/moving files
- Add tests if new components are created (ensure test coverage remains ≥ current level)
- Keep commit messages clear (e.g., "Move POST requests to controller" or "Remove obsolete model_server")
-
Validation Steps
- After changes:
- Run existing tests (ensure all pass)
- Manually verify:
- All backend calls go through
simple_adapter.py - No communication logic exists outside the controller
- All dependencies are correctly updated
- All backend calls go through
- After changes:
Deliverables:
- A clean commit history with logical groupings
- A PR description explaining changes made
- Updated documentation if public-facing APIs changed
Why this is better:
- Clear Hierarchy: Separates mandatory requirements from optional improvements
- Explicit Instructions: Uses code diffs and concrete examples
- Safety Net: Includes validation and testing steps
- Scalability: Encourages good architecture patterns without being prescriptive
- Error Prevention: Explicitly mentions dependency updates and commit best practices
- Progress Tracking: Separates tasks into actionable steps
This structure ensures the AI will:
- Prioritize the most critical changes first
- Avoid over-engineering while allowing smart improvements
- Maintain project integrity throughout the process
- Provide a clear audit trail of changes
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.