The Deska blog
Making Agents Follow Project Conventions
Learn how to improve code quality by making agents follow project conventions using system prompts, linters, and tools like Deska for better AI alignment.
· 9 min read
When working with AI coding assistants, one of the most persistent challenges is ensuring the output aligns with the existing codebase. Even the most advanced models tend to default to general best practices which might conflict with your specific architectural choices. Making agents follow project conventions is not just about aesthetics, it is about maintaining a maintainable and predictable system where every line of code looks like it was written by the same team.
The Cost of Non-Conformant AI Code
When an agent ignores your project rules, it introduces technical debt immediately. You might find a mix of functional and class-based components in a React project, or a blend of different naming conventions in a single directory. This inconsistency forces human developers to spend time refactoring AI generated code, which negates the speed benefits of using agents.
There are three primary areas where agents typically struggle:
- Architectural patterns: Choosing the wrong layer for business logic.
- Syntax and formatting: Ignoring the
PrettierorESLintrules defined in the repository. - Documentation style: Writing JSDoc when the project uses TSDoc, or vice versa.
Strategies for Instruction Craft
The most effective way to ensure an agent respects your rules is through precise instruction craft. This involves more than just a brief mention in a prompt. You must provide a structured context that the agent can refer to as a source of truth.
The System Prompt approach
Most agents allow for a system prompt or a .cursorrules style file. When you define your expectations here, you set the boundaries for every subsequent interaction. Instead of saying "be consistent", you should provide specific examples of what consistency looks like in your project.
Providing Negative Examples
Agents often learn better when told what not to do. If your project explicitly avoids certain libraries or patterns, such as using fetch instead of axios, you should list these as forbidden patterns. This reduces the search space for the agent and leads to more accurate suggestions.
Integrating Agents into the Workspace
The environment where an agent runs significantly impacts its ability to perceive project context. Traditional chat interfaces often lack the full picture of your local environment. This is where a specialized workspace becomes valuable.
Deska provides an infinite canvas where you can run multiple agents side by side. By using coding agents like Claude Code or OpenCode in separate panels, you can observe how different models interpret your conventions. Because Deska is local-first, these agents have direct access to your file system, allowing them to read your configuration files and existing code patterns.
Real-Time Validation
One way to enforce conventions is to have a terminal panel running a watcher script. In Deska, you can arrange your terminals right next to your code editor panel. If an agent writes code that violates a linting rule, the terminal will immediately show the error. You can then point the agent to the terminal output to let it self-correct.
Leveraging Multi-Agent Workflows
Sometimes a single agent is not enough to maintain strict standards. You can use a dual-agent strategy where one agent generates the code and a second agent acts as a reviewer.
- The Creator Agent: Focused on solving the functional requirement.
- The Reviewer Agent: Focused exclusively on project conventions and style guides.
- The Feedback Loop: The Reviewer provides a list of violations to the Creator.
This process is easier to manage when you can see both agent threads simultaneously. By placing these panels on an infinite canvas, you can track the conversation flow without losing sight of the source code.
The Role of Automated Tooling
While instructions are vital, they should be supported by automation. Your project should have a robust set of configuration files that agents can discover.
| Tool | Purpose in Agent Alignment |
|---|---|
| .editorconfig | Defines basic editor settings like indentation and line endings. |
| tsconfig.json | Forces the agent to respect specific TypeScript strictness levels. |
| .eslintrc | Provides a machine-readable set of stylistic rules. |
| README.md | Can be used to explain the high-level architecture to the agent. |
When these files are present, tools like Ask Deska can help navigate the project. You can ask the assistant to "find the file defining our API naming conventions" or "check if the current session follows our coding standards". The assistant can then drive the workspace to open relevant files for the agent to analyze.
Remote Monitoring and Consistency
Consistency does not stop when you leave your desk. If you are running a long refactoring task using an agent, you might need to check its progress. The Deska mobile app allows you to monitor these sessions through a secure relay. If you notice an agent starting to drift away from project conventions while you are on the move, you can intervene and provide a course correction from your phone.
FAQ
How to make AI follow coding style?
To make an AI follow a specific coding style, you should provide a comprehensive system prompt that includes your style guide. Additionally, ensure your project has clear configuration files like .eslintrc or .prettierrc that the AI can read. Using an environment where the agent has access to your full local context is essential for it to understand existing patterns.
Can agents read local project rules?
Yes, most modern coding agents can read local files if they are given permission or run in a local environment. Tools that prioritize a local-first approach allow agents to scan your directory for configuration files and existing code, which serves as a template for new contributions.
Why does my agent ignore my instructions?
Agents might ignore instructions if the context window is too cluttered or if the instructions are contradictory. It is important to keep your project conventions concise and well-structured. If an agent consistently fails, try breaking the task into smaller parts and using a dedicated reviewer agent to check for compliance.
Start Building Consistent Projects
Maintaining a clean codebase requires the right tools and a disciplined approach to agent interaction. By combining clear instruction craft with a powerful, local workspace, you can ensure that AI becomes an asset rather than a source of technical debt.
Download Deska to start organizing your agents and code in a single, infinite workspace today.