Semi-autonomous code agents require certain specific methods to be used optimally and really improve productivity.
It is the vertical news of AI that promises a real king. Semi-autonomous code agents are acclaimed by developers. They save time and focus your attention on the creation and architectural aspect rather than technical plane. But to fully optimize its productivity, IA agents specializing in code require a rigorous handling, articulated around good practices. Here are our best tips, to be used with Claude Code of Anthropic, Codex CLA D’OPENAI or Gemini Cli de Google.
1. use structured prompts
We do not prompt a code agent as we prompt chatgpt. Code agents require prompt prompts that work as real technical specifications. Contact AI as you would with a junior developer at school. Specify the technologies to use (bookstore, frameworks, API, etc.) and the way you want to implement them. Do not hesitate to give clear and detailed instructions.
The more precise the initial prompt, the more effective the AI will be and fewer errors or potential bugs or conflicts of versions there will be. Finally, examples of the exit expected by your program can clearly help AI understand your intentions and avoid timely round trips. The ideal prompt structure follows a format in three blocks: context, action, constraints. Start by specifying the technical context, then define the precise action, and finish with the specific constraints.
Example of a well -structured prompt:
CONTEXTE : Tu dois créer un site web vitrine HTML/CSS/JavaScript vanilla avec Bootstrap 5 pour le responsive. Le site contient déjà un header avec navigation, une section hero, et un footer. Pas de framework JS complexe. ACTION : Ajoute un bouton de contact fixe en bas à droite de l'écran qui ouvre une modale avec un formulaire de contact simple. CONTRAINTES : - Utilise Bootstrap 5 pour la modale et les composants du formulaire - Positionne le bouton en position fixed, bottom: 20px, right: 20px - Style le bouton avec un fond bleu (#007bff), icône envelope, et effet hover - Crée une modale Bootstrap avec formulaire (nom, email, message) - Ajoute une validation HTML5 basique (required, email type) - Implemente l'envoi du formulaire via fetch() vers /contact.php - Affiche un message de succès dans la modale après envoi - Gère les erreurs avec un message d'alerte - Rend le bouton responsive (plus petit sur mobile) - Ajoute une animation d'apparition au scroll (fadeIn) - Inclus les icônes Font Awesome pour l'enveloppe et la croix de fermeture - Assure que la modale se ferme après envoi réussi SORTIE ATTENDUE : Un bouton rond bleu avec icône enveloppe qui reste collé en bas à droite, s'agrandit au hover. Clic ouvre une modale Bootstrap classique avec formulaire 3 champs et bouton "Envoyer". Message de confirmation vert après envoi.
2. Define the context and general instructions in .MD files
Claude Code, Codex Cli and Gemini CLI allow all of them to use instruction files. The latter allow the AI to have a persistent memory which avoids repeating the project context with each session. Gemini.MD files for Gemini Cli, Claude.md for Claude Code and Codex.MD for Codex CLI allow you to define the project rules: code standards, authorized libraries, buildings of build and general architecture .on begins with a concise description of the project, then list the essential commands. Then come the code conventions to be respected and the general architecture of the project.
Example :
Description du projet Site web vitrine HTML/CSS/JS avec Nginx. Serveur de production Ubuntu. Commandes essentielles Redémarrer Nginx : sudo systemctl restart nginx Tester config Nginx : sudo nginx -t Recharger Nginx : sudo systemctl reload nginx Logs Nginx : sudo tail -f /var/log/nginx/error.log Logs accès : sudo tail -f /var/log/nginx/access.log Certificat SSL : sudo certbot renew --dry-run Conventions de code HTML : Validation W3C, sémantique CSS : Mobile-first, pas de framework JS : Vanilla JavaScript, ES6+ Images : WebP optimisées, max 500kb Architecture /var/www/html/ ├── index.html ├── css/ ├── js/ ├── images/ └── contact/ Configuration Document root : /var/www/html/ Config Nginx : /etc/nginx/sites-available/default SSL : Let's Encrypt automatique Utilisateur web : www-data
3. Effectively manage memory
This is the sensitive part of code agents: memory. Claude Code and Codex CLI only “have” 200,000 tokens of context. With large code bases, it is possible to quickly saturate the memory. The AI will then begin to forget the previous instructions or to produce incoherent responses with the initial context (except those in the .MD instructions file). Even Gemini and his million context tokens can be impacted: the longer the context, the more precision the model tends to lose.
To avoid this saturation, the recommended practice is to start a new conversation for each distinct functionality or bug. Example: a session for general architecture, another for each major component, and dedicated sessions for refactoring or debugging tasks.
Furthermore, Claude Code makes it possible to compact context memory to retain only important elements: architectural decisions, code modifications made, identified problems and their solutions. The command can be personalized via specific instructions in natural language (example “/compact focus on code samples and api usage”). In all cases, the compact automatically intervenes when 95% of the memory is saturated. However, the compact does not allow you to retain all the previous information, so you lose, anyway, in precision.
4. House advances and tasks performed
To maintain an exploitable technical history, systematically ask the agent to document his actions in a text or MD file. Ask the AI that the file captures the changes made (affected files, implemented features), the problems encountered and the solutions adopted.
Example of instruction to add to your prompt or in the instructions:
Pour chaque tâche réalisée, tu DOIS mettre à jour le fichier `AI_LOG.md` avec : - Date/heure de l'intervention - Fichiers modifiés avec résumé des changements - Problèmes rencontrés et solutions appliquées - Tests exécutés et résultats - Prochaines étapes recommandées
We thus create a persistent memory which makes it possible to trace the evolution of the project and to quickly understand the technical choices passed during reviews of code or debugging. Finally, during new sessions, the LOG allows AI to understand the latest modifications more precisely.
5. version the code generated by agents
The code produced by AI must be treated with the same rigor as that written by a junior developer. The code generated by the agent should be well version to have complete traceability and go back in the event of an error. It is therefore necessary to create dedicated branches for important modifications. It is also good to identify the commits with code generated by AI using Commit messages that specify the tool used. Example: “Feat: Add User Validation via Claude Code.”
Bonus: Use the MCP protocol
Currently, only Claude Code and Gemini RIT natively support the MCP protocol. You can directly connect your databases, Jira/Linear APIS, or image generation services. It is thus possible, for example, to create tickets, update statutes or comment on outcome directly from the console. Practical.
The agent can also question a postgreSql database, deploy the script on your production environment, automatically publish status updates in Slack/Teams, generate and send buildings by email or even create documentation pages in Confluence or concept. There are many possibilities.




