Coding with Claude, part 1
Working with AI coding tools is fascinating. You can get a good "feeling" for the statistical nature of the reasoning mechanisms within the LLM-based coding method. You will notice: 1) The non-deterministic nature, 2) the way conversations and context can "colour" or leak in unwanted ways, 3) the strange prioritization or quirks of code, 4) your good code being deleted and 5) incredibly fast and good coding. I can definitely recommend that you dive in !
To keep track of my thoughts and observations as I code with Claude, the following clear example came up yesterday. An excellent first blog post. This series is echoed in a reduced manner on LinkedIn.
Juggling patterns
Claude just wrote some code for me including the use of an UNSLOTH_ZOO_AVAILABLE flag. I suspected that the Fail-Fast pattern should be applied, and instead I was seeing a Fallback to nothing / Graceful error handling pattern.
I read a LOT of code and am used to picking up things like this in code reviews. As though I ere dealing with a human, I asked the following:
> Explain the use of UNSLOTH_ZOO_AVAILABLE. Why? BRIEF pros and cons?
The first thing Claude did was to name a pattern. Mid-levels or very promising juniors would answer this way.
- Why UNSLOTH_ZOO_AVAILABLE?
Pattern: Graceful degradation - code works even if optional dependency is missing.
To be sure, the code was also produced:
try:
from unsloth_zoo import encode_conversations_with_harmony
UNSLOTH_ZOO_AVAILABLE = True
except ImportError:
UNSLOTH_ZOO_AVAILABLE = False
Having named the pattern, Claude then went on to correctly list the pros and cons of the fallback solution as well as the alternative fail fast pattern.
Pros
- Module loads successfully even without unsloth-zoo installed
- Other features still work (basic model inference, server management)
- Clear error message only when feature is actually used
- Dev flexibility - can work on other parts without installing all deps
Cons
- Runtime errors instead of import-time errors (fail later, not sooner)
- Split code paths - harder to test both branches
- Delayed discovery - user may not know dependency is missing until they try to use it
Alternative (if we removed it)
from unsloth_zoo import encode_conversations_with_harmony # Fails immediately if missing
- Pro: Fail fast
- Con: Can't use ANY part of model_interface.py without unsloth-zoo
Finally Claude even gave the criteria under which each solution should be used:
Verdict: Good pattern for optional/advanced features. Bad for core dependencies.
All that remained was to determine which context and requirements applied to the actual class being analysed. To make this actionable, I used a yes/no question, a common technique in AI loops.
> is this feature a core requirement, answer yes/no
- Yes.
The answer allowed logical deduction as to which of the two patterns should be used.
These kinds of clear actionable sequences of steps give the hope that agentic AI can introduce further massive improvements in quality of results. However, a word of caution is necessary! AI is driven by straightforward demo cases (like this one). The value is in the eye of the beholder.
Consider: Each line of code may pose questions, which ones should the AI or even the beholder pay attention to? Patterns can help but are not 100% prescriptive. Even software engineers spend a lot of time discussing not only which patterns are the correct ones, but how to apply them. Expecting AI to master this complex skill is unreasonable.
Conclusion
This means that the raw material is there to improve coding AI Squads. However, as always, it's not the answer, it's the right question that drives the process. How do you find the right questions to ask?
Image Attribution: Header image by Shabai Liu is licensed under CC BY-SA 2.0.