Print debugging
Skill Amey-Thakur/AI-SKILLS/skills/debugging/print-debugging
Plug-and-play skills and prompts for every AI coding agent
npx -y skills add Amey-Thakur/AI-SKILLS --skill print-debuggingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 20 days oldThe repository was created 20 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Place labeled, greppable print statements at decision points to trace the real execution, then remove them cleanly. Use when a debugger is unavailable or awkward and you need to watch values flow through the actual run.
SKILL.md
2.5 KB, 555 tokens by cl100k_base, as published. Nobody here has run it
Print debugging
The oldest tool still earns its keep. When you cannot attach a debugger to a build agent, a container, or a race that only shows at full speed, a print statement reports what actually ran. Done carelessly it drowns the signal and leaks into the commit. Done well it is a fast, honest trace you can diff.
Method
- Tag every line so it is greppable. Print
>>> parse:42 rate=with the value, never a bare number. When ten lines scroll past, an untagged0.0tells you nothing about where it came from. - Print the value and its type together.
print("qty", qty, type(qty)). Half of all print-debugging surprises are a string where you expected an integer, and the type gives it away instantly. - Sit prints on boundaries, not at random. Log each value entering and leaving the suspect function. Right on entry and wrong on exit means the bug lives inside that function, and you have bracketed it in two lines.
- Make the output diffable. Emit one key-value pair per line in a stable
order, run the good case and the bad case, and
diffthe two logs. The first differing line is where behavior forks. - Prefix a sentinel that never appears in real code. Start each debug line
with a token like
ZZDEBUG.grep ZZDEBUGfinds them in the output, and the same search guarantees you can remove every one later. - Flush, and use stderr when order matters. Buffered stdout can reorder or
swallow lines when the program crashes. Print to stderr with
flush=Trueso the last line before a segfault actually reaches you. - Delete them the instant the bug is found. Grep the sentinel and strip every hit before committing. A stray debug print in shared code is noise for the next reader and a data leak in production logs.
Litmus tests
- Can you name the source line behind each output line from its tag alone?
- Do the good-run and bad-run logs diff cleanly to one first divergence?
- Does
grepfor your sentinel return zero hits before you commit?
Boundaries
For stepping through call stacks, inspecting live objects, or stopping only on a condition, a real debugger is faster: see debugger-fluency. Prints meant to survive as intentional observability belong behind a logging framework, not left as raw stdout.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.