Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion askcc/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,19 @@
Implementation:
- Read the issue's planned implementation (in comments) before writing code.
- Conform to the project's existing style, structure, and conventions.
- Write tests for every new or changed behavior.
- Make focused, minimal changes — do not refactor unrelated code.

Testing methodology — red/green TDD (non-negotiable):
- RED: write a failing test that captures the required behavior. Run it and confirm it fails \
for the right reason. Paste the failing output into your working notes.
- GREEN: write the minimum code needed to pass the test. No extra features, no speculative \
abstractions, no "while I'm here" changes.
- REFACTOR: only if there is clear duplication or unclear naming. Keep tests green throughout.
- Tests must assert on observable inputs/outputs or side effects — never by re-invoking the \
implementation's own logic to compute the expected value.
- Do NOT proceed from RED to GREEN without a confirmed failing run.
- Commit tests and implementation together.

Decisions:
- When you make a judgment call not specified in the plan, document it as: \
"DECISION: <what> because <why>."
Expand All @@ -202,6 +212,8 @@
```

Anti-rationalization — do not take these shortcuts:
- "I'll write the test after, it's faster" — Tests written after implementation verify the code, \
not the requirement. Always RED before GREEN.
- "Tests aren't needed for this small change" — Small changes cause the majority of regressions. \
Every behavioral change requires a test.
- "I'll skip linting, the CI will catch it" — Catching errors locally is cheaper than a failed CI round-trip. \
Expand Down
39 changes: 38 additions & 1 deletion tests/test_askcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
import pytest

from askcc.cli import main
from askcc.definitions import AGENT_CONFIGS, AgentAction, AgentConfig, SupportedLanguage
from askcc.definitions import (
AGENT_CONFIGS,
DEVELOP_AGENT_PROMPT,
AgentAction,
AgentConfig,
SupportedLanguage,
)
from askcc.functions import (
CheckResult,
VerificationResult,
Expand Down Expand Up @@ -229,6 +235,37 @@ def test_raises_on_missing_required_variable(self, tmp_path: Path, monkeypatch:
load_agent_config(AgentAction.PLAN)


class TestDevelopPromptTddContent:
def test_includes_red_green_tdd_block(self):
assert "Testing methodology — red/green TDD (non-negotiable):" in DEVELOP_AGENT_PROMPT

def test_includes_red_phase_with_failure_confirmation(self):
assert "RED:" in DEVELOP_AGENT_PROMPT
assert "confirm it fails" in DEVELOP_AGENT_PROMPT

def test_includes_green_phase_with_minimum_code(self):
assert "GREEN:" in DEVELOP_AGENT_PROMPT
assert "minimum code" in DEVELOP_AGENT_PROMPT

def test_includes_refactor_phase(self):
assert "REFACTOR:" in DEVELOP_AGENT_PROMPT

def test_includes_phase_gate_blocking_red_to_green(self):
assert "Do NOT proceed from RED to GREEN without a confirmed failing run." in DEVELOP_AGENT_PROMPT

def test_includes_behavioral_assertion_rule(self):
assert "observable inputs/outputs or side effects" in DEVELOP_AGENT_PROMPT

def test_requires_committing_tests_with_implementation(self):
assert "Commit tests and implementation together." in DEVELOP_AGENT_PROMPT

def test_anti_rationalization_includes_tests_after_entry(self):
assert "I'll write the test after, it's faster" in DEVELOP_AGENT_PROMPT

def test_removes_legacy_write_tests_line(self):
assert "Write tests for every new or changed behavior" not in DEVELOP_AGENT_PROMPT


class TestWritePromptContent:
def test_writes_file_with_correct_name(self):
filepath = write_prompt_content("plan", "monkut", "askcc-cli", 42, "issue content here")
Expand Down
Loading