How to Write Project Instruction Files That Make AI Coding Assistants More Effective

    This article explains what project instruction files are, how they differ from README files, and how layered loading and override rules affect them. It includes a reusable template with six sections and offers practical guidance on writing verifiable rules, keeping files short, avoiding sensitive data, and maintaining the file over time. It also covers common mistakes to avoid.

    1. Why Project Instruction Files Are Needed

    When an AI coding assistant starts a new session, it does not know the conventions of the current project. It does not know which indentation style the team uses, which directories should not be changed freely, or how tests should be run. Developers must repeat this information at the start of every conversation. This takes time, and key details are easy to leave out.

    A project instruction file stores this long-term, stable information in one document. The tool reads it automatically when a session starts. The file is closer to a new employee’s onboarding handbook than to a project README. A README is written for every visitor. It describes what the project is and how to install it. An instruction file is written for the agent that does the work. It describes how to work in this project and what not to do.

    The two documents have different readers, so they are written differently. A README can include background and vision. An instruction file should contain executable rules. For example, “Keep the code clean” gives a tool almost no guidance. “Every new function must include unit tests, and changes can only be committed after the tests pass” can be turned directly into specific behavior.

    2. Layered Loading and Override Rules

    Most AI coding tools support multiple layers of instructions. Common levels include:

    1. Organization level: issued by the IT or security team, usually containing compliance requirements and prohibited items.
    2. Project level: placed in the root directory of the code repository and shared by the team. This is the most commonly used layer.
    3. Module level: rules for a specific subdirectory or a certain type of file.
    4. Personal level: global preferences on the developer’s own machine, such as reply language or the level of detail in output.
    5. Local private level: not committed to version control, suitable for personal temporary conventions.

    The general principle is that the more specific the scope, the higher the priority. Project-level rules override general personal preferences, and module-level rules override general project-level descriptions. Therefore, team conventions should be written at the project level, and personal habits belong at the personal level. This keeps the two layers from conflicting.

    File names and loading locations differ between tools. Before you use a tool, check the official documentation for that tool to confirm the loading order in its current version. Do not rely on assumptions from experience.

    3. A Reusable Template

    The template below is organized into six dimensions: tech stack, coding standards, directory structure, testing requirements, prohibited actions, and collaboration. You can edit each section to match the actual project.

    1. # Project Instructions: [Project Name]
    2. ## Tech Stack
    3. - Frontend: [Framework name] + [Language and major version]
    4. - Backend: [Runtime and major version] + [Service framework]
    5. - Database: [Database type and major version]
    6. - Data access: [ORM or query builder]
    7. ## Coding Standards
    8. - Use single quotes for strings
    9. - Use 2 spaces for indentation
    10. - Prefer functional style for components
    11. - Do not use broad `any` type annotations
    12. ## Directory Structure
    13. src/
    14. ├── components/ # UI components
    15. ├── hooks/ # Reusable state logic
    16. ├── services/ # API call wrappers
    17. └── utils/ # General utility functions
    18. ## Testing Requirements
    19. - New features must include unit tests
    20. - Run the project's standard test command before committing
    21. - Test coverage must be at least 80%
    22. ## Prohibited Actions
    23. - Do not modify environment variable files
    24. - Do not apply database changes directly from code
    25. - Do not delete dependency directories
    26. ## Collaboration
    27. - Keep answers concise and avoid unnecessary preamble
    28. - Ask questions when requirements are unclear instead of making assumptions
    29. - When offering multiple options, explain the trade-offs of each

    4. Key Points for Each Section

    4.1 Tech Stack

    List tech stack versions down to the major version number. If the version is unclear, the tool may generate code based on common patterns in its training data, and the syntax or APIs may not match the project. Stating which data access tool the project uses also prevents the tool from mixing two query approaches in the same project.

    The tech stack section should list only the core components, not every dependency. The dependency list is maintained in the package management files. Repeating it in the instruction file only adds synchronization work.

    4.2 Coding Standards

    Coding standards should include only rules that can be verified. Formatting details are best defined by the project’s formatter and linter configuration. The instruction file should state the principles and point to those configurations:

    1. Formatting details follow the formatter configuration in the project root directory.
    2. This file covers design principles only: keep functions focused on a single responsibility, and avoid functions longer than 50 lines.

    This approach has two benefits. First, configuration files can be run by automated tools, so the rules do not depend on people remembering them. Second, when the standards change, you only need to update the configuration. The descriptions in the instruction file are less likely to go out of date.

    4.3 Directory Structure

    The directory structure section should explain the responsibility and boundaries of each directory. It should not try to list every file. The tool needs to know where new components belong and where API wrappers are written. This information is more useful than a complete file tree.

    If the project has clear layering rules, such as “the UI layer must not call the database directly,” write them out explicitly. When these rules are broken, the code often still runs, but it creates long-term structural problems. That is why they must be stated clearly.

    4.4 Testing Requirements

    The testing section should cover three things: the command to run, the criteria for passing, and how coverage is measured. A statement like “ensure quality” gives the tool nothing it can act on.

    1. Test command: run the unit test script defined by the project
    2. Passing criteria: all test cases pass, with no new failures
    3. Coverage: measured by the project's standard coverage report, with a target of at least 80%

    If the project has multiple test suites, such as unit, integration, and end-to-end tests, describe when each one should run. Otherwise, the tool may run only some of them and still report that “tests passed.”

    4.5 Prohibited Actions

    Each prohibited action should include a reason. The reason helps the tool decide how to handle edge cases. For example:

    1. - Do not modify environment variable files: they store connection settings for each environment, and changes can affect deployment.
    2. - Do not apply database changes directly: all schema changes must go through migration scripts and be reviewed.

    A bare instruction such as “do not do X” may not help the tool judge whether it applies to a similar situation. With a stated reason, the tool can infer a better approach, such as submitting a migration script instead of skipping the step.

    4.6 Collaboration

    The collaboration section determines how the tool behaves when it is uncertain. Define two categories. The first covers operations that require confirmation first, such as deleting files, modifying data, or releasing versions. The second covers small decisions the tool can make on its own, such as variable naming or comment style.

    This reduces two common problems. One is a tool that is too cautious and asks about every small detail. The other is a tool that is too proactive and makes high-impact changes without asking.

    5. Advanced Practices

    5.1 Make Rules Verifiable

    Good rules can be checked. “Code must be high quality” cannot be checked, but “public functions must declare types for their parameters and return values” can be verified with static analysis.

    1. # Not recommended
    2. - Code must be high quality
    3. # Recommended
    4. - Public functions must declare types for their parameters and return values
    5. - Database queries may only appear in the services/ directory

    5.2 Split by Module

    As a project grows, putting every rule in one file becomes unwieldy. You can move module-specific rules for the frontend, backend, or database into module-level files. The project-level file keeps the shared conventions. After the split, each module’s rules apply only when the tool works on that module, which keeps the context cleaner.

    5.3 Keep the File Short

    Longer instruction files make it easier to miss key rules. Keep the main file to one or two screens if possible. If it grows longer, split it up or remove content that configuration files already cover.

    5.4 Explain Reasons, Not Just Conclusions

    A reason helps a rule apply to new situations. When the tool encounters a case the file does not address, the reason helps it make a consistent decision.

    5.5 Keep Sensitive Information Out of the Repository

    Secrets, access tokens, and internal service addresses should not appear in the project instruction file. This file is committed with the code, so a leak could have wide impact. Store sensitive configuration in environment variables or a dedicated secrets management service. The instruction file should only say where to read the values.

    5.6 Review Regularly

    If the tool keeps making the same kind of mistake, add a rule for it. If a rule no longer applies, for example because the tech stack has changed, remove it promptly. Like code, the instruction file needs ongoing maintenance.

    5.7 Manage Changes Through Review

    The instruction file affects how everyone on the team works together. Changes should go through the same merge request process as code, with review by team members. This helps ensure the rules are understood and prevents inconsistency caused by individual edits.

    6. Common Mistakes

    First, putting every document into the instruction file. The file should contain only rules the tool must follow. Architecture design, business background, and similar material belong in separate documents, with links or paths referenced from the instruction file.

    Second, writing conflicting rules. For example, if the project-level file requires functional style but the module-level file requires class-based code, the tool cannot follow either one reliably. When conflicts occur, the more specific rule should win, and the outdated one should be deleted.

    Third, writing rules without automated checks. Rules that cannot be checked automatically depend on manual review, and some violations will slip through. Where possible, convert automatable rules into checks in configuration files.

    Fourth, failing to update the file. After a tech stack upgrade, directory restructuring, or change in team conventions, an outdated instruction file will mislead the tool. Include updates to the instruction file in the checklist for version upgrades and refactoring.

    The value of a project instruction file is that it turns a team’s implicit knowledge into clear, executable, and verifiable rules. The more specific and concise the rules are, the more reliably the tool follows them, and developers can focus on the problems that need human judgment.