AgentSkillsCN

debug-with-test

针对给定且失败的单元测试,提供查找并修复问题的指南

SKILL.md
--- frontmatter
name: debug-with-test
description: Guide for finding and fixing a problem with a given, failing unit test
user-invokable: true
argument-hint: "[test function]"

Find and Fix a Problem

  1. Use the vscode's build-in tool (execute/runTests) or the runTests tool to run the given unit tests and analyze the output carefully.

  2. Analyze the code carefully to find all possible causes of the problem.

  3. Think hard to create an extensive list of hypotheses of all possible causes of the problem.

  4. Important: Output all your hypotheses!

  5. Add extensive print statements to the code that help you confirm or disprove your hypotheses. For example:

Player tick positon += direction print "{this} moved in {direction} to {position}"

code
	let cell = getCellAt position
	print "{this} landed on cell type {cell?.type} at position {cell?.gridPos}"

6. Run the unit test again and carefully analyze the output of your print statements. The goal is to confirm one of your hypotheses. Repeat steps 1-6 until you can confirm one of your hypotheses.

  1. Once you confirmed a hypothesis, fix the problem.

  2. Repeat until the given unit test is passing.

  3. Remove all the print statements you added.