From e9c63b535d8d2d14331204e38f180e0b2c17c8ad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 01:19:34 +0000 Subject: [PATCH 1/7] Initial plan From 33834eb10685c4222a12d4c417d06c5eb01861e3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 01:22:24 +0000 Subject: [PATCH 2/7] refine test generation prompts --- ai-code-agile.el | 9 ++++++++- ai-code-autoloads.el | 1 + ai-code-harness.el | 5 ++++- prompt/tdd-diagnostics.v1.md | 2 +- prompt/tdd-with-refactoring-diagnostics.v1.md | 2 +- prompt/tdd-with-refactoring.v1.md | 2 +- prompt/tdd.v1.md | 2 +- prompt/test-after-change-diagnostics.v1.md | 2 +- prompt/test-after-change.v1.md | 2 +- snippets/ai-code-prompt-mode/create-tests | 2 +- snippets/ai-code-prompt-mode/unit-tests | 3 ++- test/test_ai-code-agile.el | 2 ++ test/test_ai-code-harness.el | 4 ++++ test/test_ai-code-package-hygiene.el | 19 +++++++++++++++++++ 14 files changed, 47 insertions(+), 10 deletions(-) diff --git a/ai-code-agile.el b/ai-code-agile.el index 99879439..cd93cfd3 100644 --- a/ai-code-agile.el +++ b/ai-code-agile.el @@ -709,8 +709,15 @@ If no such buffer is found, report a user-error." (unless has-test-buffer (user-error "No test file found in current windows. Please open a test file first")))) +(defconst ai-code--high-value-tests-instruction + " Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests." + "Instruction appended to test-writing prompts to keep generated tests focused.") + (defconst ai-code--tdd-test-pattern-instruction - "\nFollow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures." + (concat + "\nFollow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository." + ai-code--high-value-tests-instruction + " If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures.") "Instruction appended to TDD prompts to enforce the project's test pattern.") (defconst ai-code--tdd-run-test-after-this-stage-instruction diff --git a/ai-code-autoloads.el b/ai-code-autoloads.el index cb99c1c1..bc02b5aa 100644 --- a/ai-code-autoloads.el +++ b/ai-code-autoloads.el @@ -1109,6 +1109,7 @@ Disable future auto-display of the onboarding quickstart." t) (concat "If any program code changes, " "run unit-tests and follow up on the test-result (fix code if there is an error). " + "Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. " "If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures.") "\ User-provided prompt suffix for test-after-code-change.") diff --git a/ai-code-harness.el b/ai-code-harness.el index ab2dbe83..31d6f8dc 100644 --- a/ai-code-harness.el +++ b/ai-code-harness.el @@ -37,7 +37,10 @@ ;;;###autoload (defcustom ai-code-test-after-code-change-suffix - "If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures." + (concat + "If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error)." + ai-code--high-value-tests-instruction + " If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures.") "User-provided prompt suffix for test-after-code-change." :type '(choice (const nil) string) :group 'ai-code) diff --git a/prompt/tdd-diagnostics.v1.md b/prompt/tdd-diagnostics.v1.md index 9f961145..a125d2c0 100644 --- a/prompt/tdd-diagnostics.v1.md +++ b/prompt/tdd-diagnostics.v1.md @@ -1,2 +1,2 @@ Follow strict TDD stages. Do not skip stages. Stage 1 - Red: update only test code and write the smallest failing test that captures the requested behavior. Do not modify source code during Red. Stage 2 - Green: after confirming the new test fails for the expected reason, update the minimum source code needed to make it pass. Do not refactor during Green. Keep the changes narrowly scoped to the requested behavior. Only update the relevant test and source code. Do not add extra features or unrelated cleanup. Run test after each stage and output the summary of test result. For each stage, list the stage name, files changed, exact test command / result, and whether the result matches the goal of that stage. List the public API / log key / config key change if there is. -Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). +Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). diff --git a/prompt/tdd-with-refactoring-diagnostics.v1.md b/prompt/tdd-with-refactoring-diagnostics.v1.md index 8e928b52..780acd9e 100644 --- a/prompt/tdd-with-refactoring-diagnostics.v1.md +++ b/prompt/tdd-with-refactoring-diagnostics.v1.md @@ -1,2 +1,2 @@ Follow strict TDD stages. Do not skip stages. Stage 1 - Red: update only test code and write the smallest failing test that captures the requested behavior. Do not modify source code during Red. Stage 2 - Green: after confirming the new test fails for the expected reason, update the minimum source code needed to make it pass. Do not refactor during Green. Stage 3 - Blue: after Green is passing, refactor only the files changed in Red/Green. Preserve behavior and do not add features. First review the code diff (including tests) and identify the highest-impact cleanup. Then apply focused refactoring that improves readability, keeps classes/functions small and cohesive / easy to test, reduces duplication, and simplifies naming and control flow. Keep the changes narrowly scoped to the requested behavior. Only update the relevant test and source code. Do not add extra features or unrelated cleanup. Run test after each stage and output the summary of test result. For each stage, list the stage name, files changed, exact test command / result, and whether the result matches the goal of that stage. List the public API / log key / config key change if there is. -Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). +Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). diff --git a/prompt/tdd-with-refactoring.v1.md b/prompt/tdd-with-refactoring.v1.md index 8fcbfd6b..d7afa05e 100644 --- a/prompt/tdd-with-refactoring.v1.md +++ b/prompt/tdd-with-refactoring.v1.md @@ -1,2 +1,2 @@ Follow strict TDD stages. Do not skip stages. Stage 1 - Red: update only test code and write the smallest failing test that captures the requested behavior. Do not modify source code during Red. Stage 2 - Green: after confirming the new test fails for the expected reason, update the minimum source code needed to make it pass. Do not refactor during Green. Stage 3 - Blue: after Green is passing, refactor only the files changed in Red/Green. Preserve behavior and do not add features. First review the code diff (including tests) and identify the highest-impact cleanup. Then apply focused refactoring that improves readability, keeps classes/functions small and cohesive / easy to test, reduces duplication, and simplifies naming and control flow. Keep the changes narrowly scoped to the requested behavior. Only update the relevant test and source code. Do not add extra features or unrelated cleanup. Run test after each stage and output the summary of test result. For each stage, list the stage name, files changed, exact test command / result, and whether the result matches the goal of that stage. List the public API / log key / config key change if there is. - Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. + Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. diff --git a/prompt/tdd.v1.md b/prompt/tdd.v1.md index 828d3f9f..6abd08f1 100644 --- a/prompt/tdd.v1.md +++ b/prompt/tdd.v1.md @@ -1,2 +1,2 @@ Follow strict TDD stages. Do not skip stages. Stage 1 - Red: update only test code and write the smallest failing test that captures the requested behavior. Do not modify source code during Red. Stage 2 - Green: after confirming the new test fails for the expected reason, update the minimum source code needed to make it pass. Do not refactor during Green. Keep the changes narrowly scoped to the requested behavior. Only update the relevant test and source code. Do not add extra features or unrelated cleanup. Run test after each stage and output the summary of test result. For each stage, list the stage name, files changed, exact test command / result, and whether the result matches the goal of that stage. List the public API / log key / config key change if there is. - Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. + Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. diff --git a/prompt/test-after-change-diagnostics.v1.md b/prompt/test-after-change-diagnostics.v1.md index f6d71fb3..6345919b 100644 --- a/prompt/test-after-change-diagnostics.v1.md +++ b/prompt/test-after-change-diagnostics.v1.md @@ -1 +1 @@ -If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). +If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). diff --git a/prompt/test-after-change.v1.md b/prompt/test-after-change.v1.md index 65ad0237..081a2369 100644 --- a/prompt/test-after-change.v1.md +++ b/prompt/test-after-change.v1.md @@ -1 +1 @@ -If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. +If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. diff --git a/snippets/ai-code-prompt-mode/create-tests b/snippets/ai-code-prompt-mode/create-tests index d62f0702..fb4d5c9e 100644 --- a/snippets/ai-code-prompt-mode/create-tests +++ b/snippets/ai-code-prompt-mode/create-tests @@ -3,5 +3,5 @@ # key: unittests # contributor: Matic Vertačnik # -- -/architect Generate two unit tests for the provided code: one that is expected to pass and one that is expected to fail. Ensure the tests cover both success and error conditions. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. +/architect Generate a small set of high-value unit tests for the provided code. Cover only the most important success, failure, or regression behaviors that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. $0 \ No newline at end of file diff --git a/snippets/ai-code-prompt-mode/unit-tests b/snippets/ai-code-prompt-mode/unit-tests index f4c95daf..366014ad 100644 --- a/snippets/ai-code-prompt-mode/unit-tests +++ b/snippets/ai-code-prompt-mode/unit-tests @@ -6,7 +6,8 @@ /ask Generate unit tests for the following function: ${1:function} -Include tests for: +Prefer a small set of high-value tests. Cover only distinct behaviors that materially increase confidence, and do not add low-value, redundant, or duplicate tests. +Consider the most important items from: 1. Normal expected inputs 2. Edge cases 3. Invalid inputs diff --git a/test/test_ai-code-agile.el b/test/test_ai-code-agile.el index 637fee1c..3d69af5e 100644 --- a/test/test_ai-code-agile.el +++ b/test/test_ai-code-agile.el @@ -128,6 +128,8 @@ (lambda (text) (setq captured-prompt text)))) (ai-code--write-test "my-function") (should (string-match-p "TDD" captured-prompt)) + (should (string-match-p "small set of high-value tests" captured-prompt)) + (should (string-match-p "duplicate tests" captured-prompt)) (should (string-match-p "fixing the random seed" captured-prompt)) (should (string-match-p "deterministic fixtures" captured-prompt)))))) diff --git a/test/test_ai-code-harness.el b/test/test_ai-code-harness.el index dcbaa925..5d9d446f 100644 --- a/test/test_ai-code-harness.el +++ b/test/test_ai-code-harness.el @@ -30,6 +30,8 @@ (ert-deftest ai-code-test-resolve-tdd-suffix-requires-reproducible-random-tests () "Test that TDD suffix requires deterministic handling of random test data." (let ((suffix (ai-code--test-after-code-change--resolve-tdd-suffix))) + (should (string-match-p "small set of high-value tests" suffix)) + (should (string-match-p "duplicate tests" suffix)) (should (string-match-p "fixing the random seed" suffix)) (should (string-match-p "random numbers or UUIDs" suffix)) (should (string-match-p "deterministic fixtures" suffix)))) @@ -217,6 +219,8 @@ (ert-deftest ai-code-test-auto-test-inline-test-after-change-suffix-requires-reproducible-random-tests () "Test that test-after-change suffix requires deterministic random test data." (let ((suffix (ai-code--auto-test-inline-suffix-for-type 'test-after-change))) + (should (string-match-p "small set of high-value tests" suffix)) + (should (string-match-p "duplicate tests" suffix)) (should (string-match-p "fixing the random seed" suffix)) (should (string-match-p "random numbers or UUIDs" suffix)) (should (string-match-p "deterministic fixtures" suffix)))) diff --git a/test/test_ai-code-package-hygiene.el b/test/test_ai-code-package-hygiene.el index b3ed4458..4a367e77 100644 --- a/test/test_ai-code-package-hygiene.el +++ b/test/test_ai-code-package-hygiene.el @@ -30,8 +30,27 @@ (with-temp-buffer (insert-file-contents "ai-code-autoloads.el") (should (search-forward "run unit-tests and follow up on the test-result" nil t)) + (should (search-forward "small set of high-value tests" nil t)) + (should (search-forward "duplicate tests" nil t)) (should-not (search-forward "get_diagnostics MCP tool" nil t)))) +(ert-deftest ai-code-test-bundled-test-prompts-prefer-high-value-non-duplicate-coverage () + "Bundled prompts and snippets should discourage low-value duplicate tests." + (dolist (file '("prompt/test-after-change.v1.md" + "prompt/test-after-change-diagnostics.v1.md" + "prompt/tdd.v1.md" + "prompt/tdd-diagnostics.v1.md" + "prompt/tdd-with-refactoring.v1.md" + "prompt/tdd-with-refactoring-diagnostics.v1.md" + "snippets/ai-code-prompt-mode/create-tests" + "snippets/ai-code-prompt-mode/unit-tests")) + (with-temp-buffer + (insert-file-contents file) + (goto-char (point-min)) + (should (search-forward "high-value" nil t)) + (goto-char (point-min)) + (should (search-forward "duplicate tests" nil t))))) + (ert-deftest ai-code-test-ai-code-el-does-not-autoload-private-diagnostics-constant () "Private diagnostics helper constants should not be marked for autoload." (with-temp-buffer From 679855fc3a64ec9a25b7e1fae1a6eb14e4ad63ca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 01:23:51 +0000 Subject: [PATCH 3/7] address validation feedback --- ai-code-agile.el | 4 ++-- ai-code-harness.el | 2 +- test/test_ai-code-package-hygiene.el | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ai-code-agile.el b/ai-code-agile.el index cd93cfd3..68c86645 100644 --- a/ai-code-agile.el +++ b/ai-code-agile.el @@ -710,12 +710,12 @@ If no such buffer is found, report a user-error." (user-error "No test file found in current windows. Please open a test file first")))) (defconst ai-code--high-value-tests-instruction - " Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests." + "Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests." "Instruction appended to test-writing prompts to keep generated tests focused.") (defconst ai-code--tdd-test-pattern-instruction (concat - "\nFollow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository." + "\nFollow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. " ai-code--high-value-tests-instruction " If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures.") "Instruction appended to TDD prompts to enforce the project's test pattern.") diff --git a/ai-code-harness.el b/ai-code-harness.el index 31d6f8dc..0acc5eab 100644 --- a/ai-code-harness.el +++ b/ai-code-harness.el @@ -38,7 +38,7 @@ ;;;###autoload (defcustom ai-code-test-after-code-change-suffix (concat - "If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error)." + "If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). " ai-code--high-value-tests-instruction " If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures.") "User-provided prompt suffix for test-after-code-change." diff --git a/test/test_ai-code-package-hygiene.el b/test/test_ai-code-package-hygiene.el index 4a367e77..9a5e9cf1 100644 --- a/test/test_ai-code-package-hygiene.el +++ b/test/test_ai-code-package-hygiene.el @@ -47,8 +47,7 @@ (with-temp-buffer (insert-file-contents file) (goto-char (point-min)) - (should (search-forward "high-value" nil t)) - (goto-char (point-min)) + (should (search-forward "small set of high-value" nil t)) (should (search-forward "duplicate tests" nil t))))) (ert-deftest ai-code-test-ai-code-el-does-not-autoload-private-diagnostics-constant () From 5793fed642183752504fc8bba2e940feadc69f16 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 01:24:28 +0000 Subject: [PATCH 4/7] polish prompt wording --- ai-code-agile.el | 2 +- snippets/ai-code-prompt-mode/unit-tests | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ai-code-agile.el b/ai-code-agile.el index 68c86645..c15481d8 100644 --- a/ai-code-agile.el +++ b/ai-code-agile.el @@ -711,7 +711,7 @@ If no such buffer is found, report a user-error." (defconst ai-code--high-value-tests-instruction "Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests." - "Instruction appended to test-writing prompts to keep generated tests focused.") + "Instruction included in test-writing prompts to keep generated tests focused.") (defconst ai-code--tdd-test-pattern-instruction (concat diff --git a/snippets/ai-code-prompt-mode/unit-tests b/snippets/ai-code-prompt-mode/unit-tests index 366014ad..729619c2 100644 --- a/snippets/ai-code-prompt-mode/unit-tests +++ b/snippets/ai-code-prompt-mode/unit-tests @@ -7,7 +7,7 @@ Generate unit tests for the following function: ${1:function} Prefer a small set of high-value tests. Cover only distinct behaviors that materially increase confidence, and do not add low-value, redundant, or duplicate tests. -Consider the most important items from: +Prioritize: 1. Normal expected inputs 2. Edge cases 3. Invalid inputs From 8f5bafe1893fdcb2f25f543e0a96a95cd3707251 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 01:25:17 +0000 Subject: [PATCH 5/7] improve prompt readability --- ai-code-agile.el | 2 +- ai-code-autoloads.el | 2 +- prompt/tdd-diagnostics.v1.md | 2 +- prompt/tdd-with-refactoring-diagnostics.v1.md | 2 +- prompt/tdd-with-refactoring.v1.md | 2 +- prompt/tdd.v1.md | 2 +- prompt/test-after-change-diagnostics.v1.md | 6 +++++- prompt/test-after-change.v1.md | 5 ++++- snippets/ai-code-prompt-mode/create-tests | 2 +- snippets/ai-code-prompt-mode/unit-tests | 2 +- 10 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ai-code-agile.el b/ai-code-agile.el index c15481d8..5bef6d68 100644 --- a/ai-code-agile.el +++ b/ai-code-agile.el @@ -710,7 +710,7 @@ If no such buffer is found, report a user-error." (user-error "No test file found in current windows. Please open a test file first")))) (defconst ai-code--high-value-tests-instruction - "Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests." + "Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value or duplicate tests." "Instruction included in test-writing prompts to keep generated tests focused.") (defconst ai-code--tdd-test-pattern-instruction diff --git a/ai-code-autoloads.el b/ai-code-autoloads.el index bc02b5aa..6c3b5c6e 100644 --- a/ai-code-autoloads.el +++ b/ai-code-autoloads.el @@ -1109,7 +1109,7 @@ Disable future auto-display of the onboarding quickstart." t) (concat "If any program code changes, " "run unit-tests and follow up on the test-result (fix code if there is an error). " - "Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. " + "Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value or duplicate tests. " "If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures.") "\ User-provided prompt suffix for test-after-code-change.") diff --git a/prompt/tdd-diagnostics.v1.md b/prompt/tdd-diagnostics.v1.md index a125d2c0..1bd9757a 100644 --- a/prompt/tdd-diagnostics.v1.md +++ b/prompt/tdd-diagnostics.v1.md @@ -1,2 +1,2 @@ Follow strict TDD stages. Do not skip stages. Stage 1 - Red: update only test code and write the smallest failing test that captures the requested behavior. Do not modify source code during Red. Stage 2 - Green: after confirming the new test fails for the expected reason, update the minimum source code needed to make it pass. Do not refactor during Green. Keep the changes narrowly scoped to the requested behavior. Only update the relevant test and source code. Do not add extra features or unrelated cleanup. Run test after each stage and output the summary of test result. For each stage, list the stage name, files changed, exact test command / result, and whether the result matches the goal of that stage. List the public API / log key / config key change if there is. -Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). +Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). diff --git a/prompt/tdd-with-refactoring-diagnostics.v1.md b/prompt/tdd-with-refactoring-diagnostics.v1.md index 780acd9e..73952ae8 100644 --- a/prompt/tdd-with-refactoring-diagnostics.v1.md +++ b/prompt/tdd-with-refactoring-diagnostics.v1.md @@ -1,2 +1,2 @@ Follow strict TDD stages. Do not skip stages. Stage 1 - Red: update only test code and write the smallest failing test that captures the requested behavior. Do not modify source code during Red. Stage 2 - Green: after confirming the new test fails for the expected reason, update the minimum source code needed to make it pass. Do not refactor during Green. Stage 3 - Blue: after Green is passing, refactor only the files changed in Red/Green. Preserve behavior and do not add features. First review the code diff (including tests) and identify the highest-impact cleanup. Then apply focused refactoring that improves readability, keeps classes/functions small and cohesive / easy to test, reduces duplication, and simplifies naming and control flow. Keep the changes narrowly scoped to the requested behavior. Only update the relevant test and source code. Do not add extra features or unrelated cleanup. Run test after each stage and output the summary of test result. For each stage, list the stage name, files changed, exact test command / result, and whether the result matches the goal of that stage. List the public API / log key / config key change if there is. -Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). +Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). diff --git a/prompt/tdd-with-refactoring.v1.md b/prompt/tdd-with-refactoring.v1.md index d7afa05e..ad5e7612 100644 --- a/prompt/tdd-with-refactoring.v1.md +++ b/prompt/tdd-with-refactoring.v1.md @@ -1,2 +1,2 @@ Follow strict TDD stages. Do not skip stages. Stage 1 - Red: update only test code and write the smallest failing test that captures the requested behavior. Do not modify source code during Red. Stage 2 - Green: after confirming the new test fails for the expected reason, update the minimum source code needed to make it pass. Do not refactor during Green. Stage 3 - Blue: after Green is passing, refactor only the files changed in Red/Green. Preserve behavior and do not add features. First review the code diff (including tests) and identify the highest-impact cleanup. Then apply focused refactoring that improves readability, keeps classes/functions small and cohesive / easy to test, reduces duplication, and simplifies naming and control flow. Keep the changes narrowly scoped to the requested behavior. Only update the relevant test and source code. Do not add extra features or unrelated cleanup. Run test after each stage and output the summary of test result. For each stage, list the stage name, files changed, exact test command / result, and whether the result matches the goal of that stage. List the public API / log key / config key change if there is. - Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. + Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. diff --git a/prompt/tdd.v1.md b/prompt/tdd.v1.md index 6abd08f1..ee6f6cf2 100644 --- a/prompt/tdd.v1.md +++ b/prompt/tdd.v1.md @@ -1,2 +1,2 @@ Follow strict TDD stages. Do not skip stages. Stage 1 - Red: update only test code and write the smallest failing test that captures the requested behavior. Do not modify source code during Red. Stage 2 - Green: after confirming the new test fails for the expected reason, update the minimum source code needed to make it pass. Do not refactor during Green. Keep the changes narrowly scoped to the requested behavior. Only update the relevant test and source code. Do not add extra features or unrelated cleanup. Run test after each stage and output the summary of test result. For each stage, list the stage name, files changed, exact test command / result, and whether the result matches the goal of that stage. List the public API / log key / config key change if there is. - Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. + Follow the test-code pattern in the current project. Write the test-code in the test-file. If the test-file does not exist, create it using the same test-filename pattern used in this repository. Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. diff --git a/prompt/test-after-change-diagnostics.v1.md b/prompt/test-after-change-diagnostics.v1.md index 6345919b..6d6d8a6e 100644 --- a/prompt/test-after-change-diagnostics.v1.md +++ b/prompt/test-after-change-diagnostics.v1.md @@ -1 +1,5 @@ -If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). +If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). +Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. +Do not add low-value or duplicate tests. +If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. +Before editing, record a diagnostics baseline by calling the diagnostics_baseline MCP tool. After each edit, call the get_diagnostics MCP tool with since="baseline" for the touched files and do not finish until its status is "clean" (no new diagnostics versus the baseline). diff --git a/prompt/test-after-change.v1.md b/prompt/test-after-change.v1.md index 081a2369..9f057e18 100644 --- a/prompt/test-after-change.v1.md +++ b/prompt/test-after-change.v1.md @@ -1 +1,4 @@ -If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. +If any program code changes, run unit-tests and follow up on the test-result (fix code if there is an error). +Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. +Do not add low-value or duplicate tests. +If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. diff --git a/snippets/ai-code-prompt-mode/create-tests b/snippets/ai-code-prompt-mode/create-tests index fb4d5c9e..5c6c200f 100644 --- a/snippets/ai-code-prompt-mode/create-tests +++ b/snippets/ai-code-prompt-mode/create-tests @@ -3,5 +3,5 @@ # key: unittests # contributor: Matic Vertačnik # -- -/architect Generate a small set of high-value unit tests for the provided code. Cover only the most important success, failure, or regression behaviors that materially increase confidence. Do not add low-value, redundant, or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. +/architect Generate a small set of high-value unit tests for the provided code. Cover only the most important success, failure, or regression behaviors that materially increase confidence. Do not add low-value or duplicate tests. If the tests use random values (for example random numbers or UUIDs), make them reproducible by fixing the random seed or replacing them with deterministic fixtures. $0 \ No newline at end of file diff --git a/snippets/ai-code-prompt-mode/unit-tests b/snippets/ai-code-prompt-mode/unit-tests index 729619c2..497de8e9 100644 --- a/snippets/ai-code-prompt-mode/unit-tests +++ b/snippets/ai-code-prompt-mode/unit-tests @@ -6,7 +6,7 @@ /ask Generate unit tests for the following function: ${1:function} -Prefer a small set of high-value tests. Cover only distinct behaviors that materially increase confidence, and do not add low-value, redundant, or duplicate tests. +Prefer a small set of high-value tests. Cover only distinct behaviors that materially increase confidence, and do not add low-value or duplicate tests. Prioritize: 1. Normal expected inputs 2. Edge cases From d3778031d97c74fd3e89ecc37c749f29f6c47401 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 01:25:59 +0000 Subject: [PATCH 6/7] align prompt instruction wording --- ai-code-agile.el | 5 ++++- snippets/ai-code-prompt-mode/unit-tests | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ai-code-agile.el b/ai-code-agile.el index 5bef6d68..42349c16 100644 --- a/ai-code-agile.el +++ b/ai-code-agile.el @@ -710,7 +710,10 @@ If no such buffer is found, report a user-error." (user-error "No test file found in current windows. Please open a test file first")))) (defconst ai-code--high-value-tests-instruction - "Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value or duplicate tests." + (concat + "Prefer a small set of high-value tests. Cover only distinct behaviors, " + "important edge cases, or regressions that materially increase confidence. " + "Do not add low-value or duplicate tests.") "Instruction included in test-writing prompts to keep generated tests focused.") (defconst ai-code--tdd-test-pattern-instruction diff --git a/snippets/ai-code-prompt-mode/unit-tests b/snippets/ai-code-prompt-mode/unit-tests index 497de8e9..6246710d 100644 --- a/snippets/ai-code-prompt-mode/unit-tests +++ b/snippets/ai-code-prompt-mode/unit-tests @@ -6,7 +6,7 @@ /ask Generate unit tests for the following function: ${1:function} -Prefer a small set of high-value tests. Cover only distinct behaviors that materially increase confidence, and do not add low-value or duplicate tests. +Prefer a small set of high-value tests. Cover only distinct behaviors, important edge cases, or regressions that materially increase confidence. Do not add low-value or duplicate tests. Prioritize: 1. Normal expected inputs 2. Edge cases From e13bf0b2ba046af1f1be8585a9ce4a3a98936618 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 01:26:33 +0000 Subject: [PATCH 7/7] polish validation nits --- ai-code-agile.el | 4 +++- test/test_ai-code-package-hygiene.el | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ai-code-agile.el b/ai-code-agile.el index 42349c16..a5a04feb 100644 --- a/ai-code-agile.el +++ b/ai-code-agile.el @@ -714,7 +714,9 @@ If no such buffer is found, report a user-error." "Prefer a small set of high-value tests. Cover only distinct behaviors, " "important edge cases, or regressions that materially increase confidence. " "Do not add low-value or duplicate tests.") - "Instruction included in test-writing prompts to keep generated tests focused.") + "Instruction included in test-writing prompts to emphasize quality over quantity. +This guidance exists to discourage AI from generating excessive, low-value, or +duplicate tests.") (defconst ai-code--tdd-test-pattern-instruction (concat diff --git a/test/test_ai-code-package-hygiene.el b/test/test_ai-code-package-hygiene.el index 9a5e9cf1..7645de76 100644 --- a/test/test_ai-code-package-hygiene.el +++ b/test/test_ai-code-package-hygiene.el @@ -34,7 +34,7 @@ (should (search-forward "duplicate tests" nil t)) (should-not (search-forward "get_diagnostics MCP tool" nil t)))) -(ert-deftest ai-code-test-bundled-test-prompts-prefer-high-value-non-duplicate-coverage () +(ert-deftest ai-code-test-bundled-prompts-contain-high-value-guidance () "Bundled prompts and snippets should discourage low-value duplicate tests." (dolist (file '("prompt/test-after-change.v1.md" "prompt/test-after-change-diagnostics.v1.md"