Project-Level AI Coding Assistant Instructions: A Writing Guide

    Learn how to write and maintain project-level instruction files for AI coding assistants, covering repository structure, technical boundaries, commands, coding standards, security, task workflows, and acceptance criteria. Includes a reusable template and guidance on integrating instructions into code review and ongoing maintenance.

    Project-level instruction files typically live in the root of a code repository. They use natural language to explain the project’s context, technical boundaries, directory responsibilities, common commands, coding standards, security requirements, task workflow, and acceptance criteria to an AI coding assistant.

    These files do not replace project documentation, and longer is not necessarily better. Their purpose is to turn frequently repeated, easily overlooked, and mandatory engineering constraints into version-controlled context that teams can review and assistants can act on.

    Well-written instructions help an assistant locate problems faster, avoid unrelated changes, and run verification commands more consistently. Poor instructions create conflicting rules, add context noise, and can steer changes in the wrong direction.

    1. Define What the Instruction File Should Solve

    A project-level instruction file should address at least four needs:

    1. Reduce repeated explanations. The runtime, dependency management process, test commands, and directories that require special care should not need to be explained in every conversation.
    2. Set behavioral boundaries. The assistant should read relevant module documentation before editing code, update tests and documentation when public interfaces change, and never commit secrets or sensitive data.
    3. Capture engineering knowledge. Architectural layers, dependency direction, error-handling conventions, and logging requirements should be recorded as short statements and checklists.
    4. Provide a path to acceptance. Specify the minimum necessary checks after a task and how the assistant should report changes, test results, and remaining risks.

    The file should not become an encyclopedia of the project. Prioritize information the assistant must know to do its work correctly, especially where mistakes are likely. Keep background information brief and make constraints and commands specific.

    2. Ten Categories to Cover

    2.1 Project Overview and Goals

    Use one to three sentences to explain what the project does, who uses it, and its current development stage.

    Also state explicit non-goals to prevent scope expansion. For example: “During this phase, fix defects only; do not introduce new frameworks.”

    2.2 Technology Stack and Version Boundaries

    Document the runtime and supported version range, how dependencies are managed, and the conditions for adding dependencies.

    Technology names alone are not enough. Define the boundary: “Any new dependency must include a justification and an assessment of package size and license implications.”

    2.3 Directory Structure and Module Responsibilities

    List key directories and explain their responsibilities. Identify entry-point code, business logic, infrastructure code, tests, and scripts.

    Make restrictions on cross-layer calls explicit.

    2.4 Build, Test, and Quality Commands

    Provide commands for installing dependencies, starting the project locally, running unit and integration tests, performing static checks, and building the project.

    In the completed instruction file, commands must be directly executable. If a command category does not apply, write “None” so the assistant does not guess.

    2.5 Coding Standards and Style

    “Follow the existing style” is not enough. Define verifiable rules for naming, error handling, log fields, comments, and public interface documentation.

    Keep the rule set focused. Prioritize mistakes that occur frequently rather than cataloging every possible preference.

    2.6 Architecture and Dependency Rules

    Explain module dependency direction, reuse of shared abstractions, database access boundaries, and the process for changing interfaces.

    For rules that are easy to misunderstand, such as “Do not put business logic in the entry-point layer,” include both an acceptable example and a prohibited example.

    2.7 Security, Compliance, and Data Boundaries

    State that tokens, secrets, and personal data must not appear in the repository or logs. External service calls must use controlled configuration, and error messages must not expose sensitive fields.

    When connecting to model services, inject credentials through environment variables or controlled local configuration. Do not store them in version control.

    2.8 Task Workflow

    A consistent workflow can be:

    1. Read the project instructions and relevant module documentation.
    2. Present a change plan and identify the affected scope.
    3. Make small, focused changes.
    4. Run the minimum necessary verification.
    5. Summarize changes and remaining risks.

    An explicit workflow makes it less likely that the assistant will skip validation.

    2.9 Verification and Delivery Checklist

    Include checks for requirement coverage, passing tests, static checks, absence of sensitive information, documentation updates, and compatibility notes.

    Each item should be easy to mark complete and independently review.

    2.10 Response Format and Communication

    Define a stable response structure. For example, require the assistant to give the outcome first, followed by changed files, verification commands, test results, and unverified risks.

    Consistent reporting reduces review effort.

    3. Writing Principles: Specific, Verifiable, and Prioritized

    Prefer Concrete Rules to General Advice

    “Pay attention to code quality” is not actionable.

    “Changes to public functions must include unit tests and describe compatibility implications in the change summary” is much easier to verify.

    Establish Priorities

    Explain how to resolve competing rules. Security takes priority over style. Reusing an existing shared abstraction takes priority over a local optimization that would duplicate it.

    Organize Instructions in Layers

    Keep global rules in the project-level file. Put module-specific details in module documentation so the root file does not grow unnecessarily.

    Keep Commands Together

    Place common commands in one predictable section. This reduces the need for the assistant to infer how the project works.

    Eliminate Contradictions

    Do not include conflicting instructions such as “Never add dependencies” and “Prefer introducing established libraries” without explaining when each applies.

    Include Only What Is Necessary

    Every rule should answer: “During which task would the assistant need this?”

    If there is no clear answer, reconsider whether it belongs in the file.

    Use Examples Where Interpretation Is Risky

    For architectural rules that are easily misunderstood, show a recommended approach and a prohibited approach.

    4. Reusable Template

    Replace the placeholders below with project-specific information. Command entries in the finished file must contain executable commands or “None.”

    1. # Project-Level AI Coding Assistant Instructions
    2. ## 1. Project Overview
    3. - Goal: <one-sentence description>
    4. - Primary users: <user types>
    5. - Current stage: <development/maintenance/refactoring>
    6. - Non-goals: <work explicitly excluded from this phase>
    7. ## 2. Technical Boundaries
    8. - Runtime: <runtime and supported version range>
    9. - Dependency management: <dependency management method>
    10. - New dependencies: <approval required/prohibited/conditions for use>
    11. ## 3. Directory Responsibilities
    12. - <directory A>: <responsibility>
    13. - <directory B>: <responsibility>
    14. - <test directory>: <how tests are organized>
    15. ## 4. Common Commands
    16. - Install dependencies: <command>
    17. - Start locally: <command>
    18. - Unit tests: <command>
    19. - Integration tests: <command>
    20. - Static checks: <command>
    21. - Build: <command>
    22. Commands must be directly executable.
    23. If a category does not apply, write "None."
    24. ## 5. Coding and Architecture Rules
    25. - Update documentation and tests when public interfaces change.
    26. - Keep business logic out of the entry-point layer.
    27. - Reuse existing abstractions rather than duplicating them.
    28. - Preserve context when handling errors; do not swallow exceptions.
    29. ## 6. Security Boundaries
    30. - Do not commit secrets, tokens, or personal data.
    31. - Do not log sensitive fields.
    32. - External service calls must use controlled configuration.
    33. ## 7. Task Workflow
    34. 1. Read this file and the relevant module documentation.
    35. 2. Present a change plan, affected scope, and verification approach.
    36. 3. Make small changes and avoid unrelated refactoring.
    37. 4. Run the minimum necessary verification.
    38. 5. Summarize changed files, test results, and unverified risks.
    39. ## 8. Acceptance Checklist
    40. - [ ] Requirements are covered
    41. - [ ] Tests pass
    42. - [ ] Static checks pass
    43. - [ ] No sensitive information is included
    44. - [ ] Documentation and change notes are updated
    45. ## 9. Response Format
    46. State the outcome first, then list changed files, verification
    47. commands, test results, and unverified risks.

    5. Integrate Instructions into the Development Workflow

    Before writing the instruction file, prepare the basic environment: the runtime, version control client, terminal, and model service connection.

    Model service setup typically includes authentication tokens, service endpoints, timeouts, model mappings, and controls on unnecessary traffic. Inject credentials through environment variables or controlled local configuration rather than committing them to the repository.

    Set timeout limits according to task type. Lightweight and complex tasks can be mapped to models with different capabilities to balance cost and effectiveness. Refer to the tool’s official documentation for the exact configuration fields, and do not hardcode sensitive information in project files.

    Once the environment is ready, use the instruction file as part of the task workflow:

    • At the start of a task, read the project-level instructions, then the relevant module documentation.
    • Before editing, provide a plan.
    • After editing, run the minimum necessary verification.
    • Finish with a summary in the required format.

    For team use, include the instruction file in code review. Changes to rules should explain their rationale and affected scope.

    Continuous integration can check whether documented commands still work, documentation links remain valid, and sensitive information has been accidentally committed.

    6. Maintenance and Measurement

    Instruction files must evolve with the project. Review and update them when:

    • Build or test commands change.
    • Directory responsibilities change.
    • New security requirements are introduced.
    • Reviews reveal recurring problems.
    • The assistant repeatedly makes the same type of incorrect change.

    Measurement does not need to be complicated. Useful indicators include how often the team repeats explanations, the number of unrelated files changed, test pass rates, review rework, and task completion time.

    Use these indicators to find gaps in the instructions, not as a reason to keep adding rules.

    7. Common Mistakes

    Common problems include:

    • Turning the instruction file into a project encyclopedia.
    • Documenting style without defining verification requirements.
    • Omitting commands and forcing the assistant to guess.
    • Including contradictory rules.
    • Storing tokens or internal addresses in the file.
    • Adding so many restrictions that normal tasks cannot proceed.
    • Leaving instructions unchanged until they no longer match the code.

    The remedy is to keep the file concise, specific, and verifiable, with a clear review and update process.

    Before adopting the file, check that:

    • The project goal is clear in one sentence.
    • Key directory responsibilities are defined.
    • Common commands can be copied and executed.
    • Architecture and security rules are verifiable.
    • The task workflow is consistent.
    • Acceptance criteria form a reviewable checklist.
    • Sensitive information is excluded.
    • The file is version-controlled and reviewed regularly.

    A project-level instruction file improves an AI coding assistant’s efficiency and consistency when it captures the constraints that matter, gives clear verification steps, and stays aligned with the repository.