Debug Go Cryptography Code with Claude Code
Job to be done: Debug low-level Go cryptography code with AI
🇳🇬 Ways to use this in Nigeria
Ideas to get you started, adapt to your situation.
- Student
Debug your Go programming assignment code with Claude Code to fix failing tests before submission.
- 9-5 employee
Fix a complex bug in your company's Go backend service using Claude Code and passing tests.
What you’ll get
A reliable method for getting an AI to find and fix a hard, low-level bug fast, the kind that can eat a whole day. The key is giving it three things: a failing test it can run, the code, and your best hunch. The worked example is real: the author fixed a subtle Go cryptography bug (signatures that always failed to verify) in minutes. The same method works for any bug you can pin down with a failing test. It is intermediate: you use a terminal and a test command.
Tools you need
- Claude Code (paid): an AI coding assistant that runs in your terminal and can read your files and run your tests itself. Needs a paid plan or credits. (The free Claude, ChatGPT, or Gemini chat apps can do a lighter version where you paste in the code yourself.)
- Go (free): the language in the example. The method is the same in any language.
Steps
-
Reproduce the failing test: make sure your test fails reliably first, so the AI has a clear target. Run your test command and confirm the failure, for example:
FAIL: TestVector (0.00s) mldsa_test.go:47: Verify: mldsa: invalid signature -
Open Claude Code in your project: launch it in the project folder so it can read your code and run the test command for you. (Use the most capable model you have access to; the author used Opus.)
-
Give it a focused debugging prompt: describe the bug, tell it the exact test command and where the code is, and add any hunch you have. The author’s prompt (adapt the paths to yours):
I implemented ML-DSA in the Go standard library, and it all works except that verification always rejects the signatures. I know the signatures are right because they match the test vector. Run the tests with: bin/go test [your module path]. The code is in [your code directory]. Find why the signatures do not verify. ultrathink. I spot-checked and w1 is different from the signing one.(“ultrathink” is a keyword that tells Claude to reason harder before answering.)
-
Let it analyze and propose a fix: give it a few minutes. It runs the test, reads the code, and comes back with an explanation and a fix. (In the example, it found a value was effectively being processed twice.)
-
Review and refine, do not accept blindly: read its explanation and check the change makes sense. The author improved on the AI’s first “mediocre fix” to make it cleaner. Apply the version you understand.
-
Re-run the test to confirm: run the same command from step 1. It should now pass, with no more
FAIL.
Original source
Based on Bogdanp’s account, shared on Hacker News and his blog, of how Claude Code rapidly pinpointed a complex low-level bug in his new Go implementation of the ML-DSA signature algorithm.
Notes & variations
- Free-tier alternative: no Claude Code? Paste the failing test output and the relevant code into the free Claude, ChatGPT, or Gemini chat and ask the same question. You lose the “it runs your tests itself” convenience but the approach holds.
- Common mistake: describing the problem without giving the actual code or test. Without them, the AI can only guess and gives generic, unhelpful advice.
- Tip for better results: state your hypothesis and what you have already checked (as the author did with the
w1hint). It focuses the AI on the right area instead of re-investigating everything.