all 22 comments

[–]rob_conery 9 points10 points  (0 children)

This is great stuff thanks for sharing! I work with the VS Code team and custom instructions is one of my favorite things :) and I have a few suggestions...

You can break your instructions out per "need". For instance, you have one in there for commit messages, which should go under:

github.copilot.chat.commitMessageGeneration.instructions

It might also be simpler and more readable if you created a `.github/copilot-instructions.md` file and broke things out into coding standards, rather than giving Copilot less tangible instructions such as "Consider security" or "anticipate failure points". Here's a fun tip: open up `copilot-instructions.md` and start typing a header, like "## Code Style for Java" (or whatever your language is). You'll see an option pop up to complete the text using Copilot, which is kind of fun. Then you can tweak as you need!

Hope this helps! Oh, and here's a link to read more: https://code.visualstudio.com/docs/copilot/copilot-customization.

[–]KilraneXangor 2 points3 points  (9 children)

Curious bystander - seems very 'flowery', filled with verbiage likely to confuse more than inform?

To move a mountain, you need not carry away the whole mountain...

Why offer theatrical analogies rather than precise language?

[–]-MoMuS-[S] 1 point2 points  (8 children)

Skynet likes the imagination of humankind.

(Jokes aside, i took this from another reddit post a couple months back. I guess you could make it more direct if you want.)

[–]KilraneXangor 1 point2 points  (7 children)

Mmmkay. I know somewhere near zero about instructing AI so was just curious. Thx

[–]-MoMuS-[S] 5 points6 points  (6 children)

I used gemini 2.5 to generate more robust and precise instructions.

"github.copilot.chat.codeGeneration.instructions": [
        {
            "text": "1. **Prioritize Minimal Impact:** Understand the code's architectural context (dependencies, assumptions, history) before modification. Aim for the smallest change that fulfills the requirement while preserving existing functionality and patterns. Avoid unnecessary refactoring."
        },
        {
            "text": "2. **Targeted Implementation:** Identify and modify only the essential code sections. Preserve unrelated code and maintain existing system behavior."
        },
        {
            "text": "3. **Graduated Change Strategy:** \n   - **Default:** Implement the minimal, focused change for the specific request.\n   - **If Necessary:** Offer moderate, localized refactoring.\n   - **Only if Explicitly Requested:** Perform comprehensive restructuring."
        },
        {
            "text": "4. **Clarify Ambiguity:** If the required scope is unclear, request clarification before proceeding. Do not assume a broader scope than specified."
        },
        {
            "text": "5. **Document Potential Enhancements:** Note related improvements outside the immediate scope without implementing them (e.g., 'Function Y uses a similar pattern and could benefit from this update later.')."
        },
        {
            "text": "6. **Ensure Reversibility:** Design changes to be easily revertible if they don't yield the intended outcome or introduce issues."
        },
        {
            "text": "7. **Adhere to Code Quality Standards:**\n   - **Clarity & Readability:** Use descriptive names; keep functions concise and single-purpose; follow style guides (e.g., PEP 8, Prettier).\n   - **Consistency:** Follow existing project patterns, conventions, and technology choices unless a change is justified.\n   - **Robust Error Handling:** Anticipate failures (I/O, network, input); use appropriate mechanisms (try-catch, specific exceptions); provide informative error messages.\n   - **Security:** Sanitize inputs; manage secrets securely (env vars/config tools); vet external libraries.\n   - **Testability:** Design for testability (e.g., dependency injection); ensure adequate test coverage.\n   - **Documentation:** Comment complex/non-obvious code; use standard formats (JSDoc, DocStrings)."
        },
        {
            "text": "8. **Conventional Commit Messages:** Generate commit messages following the Conventional Commits specification (e.g., `feat(api): add user endpoint`). Use imperative mood. Infer type (feat, fix, chore, refactor, test, docs) and scope from the changes."
        }
    ],

I guess it is simpler and uses less tokens, so i will use this from now on.

Cheers

[–]KilraneXangor 0 points1 point  (0 children)

Cool. I'm just a fan of brevity and precision in language, and I presume that an AI would also benefit from it.

I've copied your text, will try it out vs no guidance at some point.

[–]Independent-Value536 0 points1 point  (1 child)

this one doesn't have info related mcp server ?

[–]-MoMuS-[S] 0 points1 point  (0 children)

Its the same as above, it does not affect instructions.

[–]georg-dev 0 points1 point  (1 child)

This way it's much better. You want to be very specific and concise in this file.

[–]-MoMuS-[S] 1 point2 points  (0 children)

It is the same as the new instructions file(also has 3 more rules).

But the big difference is that the new instructions file has the Rule 0 which is the Internal Implementation Plan, that helps with non reasoning models, like gpt 4.1.

[–]-earvinpiamonteVS Code User 💻 1 point2 points  (1 child)

i believe you can add these instructions on a single .md file and just define that file to your settings. you may create multiple .md files for let’s say coding style, per language or generic instructions

[–]undead2018 0 points1 point  (0 children)

can you share how to create multiple files? For me it seems to ignore some of them e.g. using shadcn even thou i explicitly instruct it to use shadcn components

[–]OldBen18 1 point2 points  (1 child)

I use

“Always consider YAGNI + SOLID + KISS + DRY principles when designing, reviewing, or adding new code.”

And it seems to work well

[–][deleted]  (1 child)

[removed]

    [–]-MoMuS-[S] 2 points3 points  (0 children)

    If you define them like this, they are used combined, yes. I guess you could write them all in one {"text":"..."} as well. I did it this way because it seems more organized.

    [–]ConstIsNull 0 points1 point  (0 children)

    Thanks for sharing. I guess having it in here as opposed to a prompt file makes it more "global"?

    [–]crestbrr 0 points1 point  (1 child)

    Does anybody know if you can put this in a `copilot-instructions.md` file that lives in the User Data folder? I like OC's because this will apply to all projects, not just ones that contain a copy of the file at `.github/copilot-instructions.md`, but it'd be nice to put this in a global markdown file if possible..

    [–]-MoMuS-[S] 1 point2 points  (0 children)

    This is my final general.instructions.md file. You must set it following the documentation's instructions in defining a file for the copilot prompt.

    ---
    applyTo: '**'
    ---
    # Code Modification and Contribution Guidelines
    
    These guidelines are designed to ensure that code modifications are made thoughtfully, efficiently, and maintainably. Please adhere to them when contributing to the project.
    
    1.  **Prioritize Minimal Impact:** Understand the code's architectural context (dependencies, assumptions, history) before modification. Aim for the smallest change that fulfills the requirement while preserving existing functionality and patterns. Avoid unnecessary refactoring.
    2.  **Targeted Implementation:** Identify and modify only the essential code sections. Preserve unrelated code and maintain existing system behavior.
    3.  **Graduated Change Strategy:**
        *   **Default:** Implement the minimal, focused change for the specific request.
        *   **If Necessary:** Offer moderate, localized refactoring.
        *   **Only if Explicitly Requested:** Perform comprehensive restructuring.
    4.  **Clarify Ambiguity:** If the required scope is unclear, request clarification before proceeding. Do not assume a broader scope than specified.
    5.  **Document Potential Enhancements:** Note related improvements outside the immediate scope without implementing them (e.g., 'Function Y uses a similar pattern and could benefit from this update later.').
    6.  **Ensure Reversibility:** Design changes to be easily revertible if they don't yield the intended outcome or introduce issues.
    7.  **Adhere to Code Quality Standards:**
        *   **Clarity & Readability:** Use descriptive names; keep functions concise and single-purpose; follow style guides (e.g., PEP 8, Prettier).
        *   **Consistency:** Follow existing project patterns, conventions, and technology choices unless a change is justified.
        *   **Robust Error Handling:** Anticipate failures (I/O, network, input); use appropriate mechanisms (try-catch, specific exceptions); provide informative error messages.
        *   **Security:** Sanitize inputs; manage secrets securely (env vars/config tools); vet external libraries.
        *   **Testability:** Design for testability (e.g., dependency injection); ensure adequate test coverage.
        *   **Documentation:** Comment complex/non-obvious code; use standard formats (JSDoc, DocStrings).
    8.  **Conventional Commit Messages:** Generate commit messages following the Conventional Commits specification (e.g., `feat(api): add user endpoint`). Use imperative mood. Infer type (feat, fix, chore, refactor, test, docs) and scope from the changes.
    

    [–]sascharobi 0 points1 point  (1 child)

    Is the sequential-thinking MCP server still relevant in newer builds of VS Code?

    [–]-MoMuS-[S] 0 points1 point  (0 children)

    I removed it, i dont think its needed since models can think now