Check the previous post for details on this evolution of this Python music composition software.
I was trying to test the 4th iteration and was having trouble figuring out how to name the more complex chords in a way that the software could parse.
So I asked Claude: for this system please print all possible chord names for the key of C.
I was just seeking a reference in a single key so that I could get the names right, but Claude decided to do more – to improve the software overall, adding a feature that displays all chords in a specified key.
Very useful, but I was getting more demanding: this is great, but can you also display the different notes that make up each chord?
Again, Claude went over and beyond what I requested, providing not only note names but intervalic relations for each chord, like so:

This info became available in the software via a new command: chords A minor, etc.
This capacity to not only action requests but to take relevant initiative demonstrates the astonishing powers of this agentive coding system.
Yet Another Iteration (6)
Still, there was a remaining error. Somehow strange to think of Claude writing code that contains bugs. But I guess not really, since AI is constitutively stochastic and works with existing bodies of humanly written code. There are bound to be errors in that overall statistically analysable corpus. Nonetheless, you’d think that Claude would be especially attuned to them, less at the level of the LLM process than in terms of exhaustively checking the functioning of any given numerically definable code system. But I’m writing without any sufficient understanding of the combination of processes that make Claude possible.
I should note that before I could interact with Claude any further I had to wait five hours. I had exhausted my number of free tier enquiries. Not too bad considered how much we had accomplished already – although, to be honest, I’m load to take credit for any authorship of this software project. Nor do I want to lend Claude any more agency than I have already recognised. Ultimately, it seems more like Claude represents a really quick, compressed and task relevant way of drawing upon the existing stock of software writing and music theory knowledge. The system provides a far better means of drawing upon this body of knowledge than if I were attempt to have encyclopaedic knowledge myself. No doubt, I do need to make some effort to understand code and music, but not to hold everything within myself as some permanent stock. This is not possible in any case, or only for a brief moment before other issues and imperatives push that knowledge aside, making it once again inaccessible. Before Claude, my only option was to remain resolutely focused on the one topic so that the limits of my knowledge/capacity were not constantly, untenably tested. Now, however, when I am typically drawn in multiple directions and require a range of expertise that I can not possible humanly master, AI becomes a means of having what Plato describes as the ‘wild birds’ of knowledge ready at hand (Theaetetus).
So, another prompt: a couple of revisions. Firstly, I am encountering the following error, ‘Error generating chords for C major: ‘NoneType’ object is not subscriptable’. This is based on my input ‘chords C major’. Can you please fix this. Secondly, can you add a complementary command that shows all the notes in any given scale. Can you make sure that this command also enables accessing modals scales (Dorian, Phrygian, etc.).
Claude responded: I’ll fix the error and add the scale display feature with modal support. Let me address both issues.
After a minute or so I received the revised program and this explanation:
Perfect! I’ve fixed both issues:
🔧 Fixed the Error
The error was caused by missing error handling in the chord parsing functions. I’ve added proper try-catch blocks to handle any parsing issues gracefully.
🎵 Added Scale Display Feature
New Command: scale [root] [type]
Examples:
scale C major
scale A dorian
scale F# phrygian
scale Bb blues
🎼 Supported Scale Types:
🏰 Church Modes:
- Ionian (Major) – bright, happy
- Dorian – jazzy, sophisticated
- Phrygian – Spanish, exotic
- Lydian – dreamy, ethereal
- Mixolydian – bluesy, rock
- Aeolian (Natural Minor) – sad, melancholic
- Locrian – unstable, dissonant
🎹 Other Scales:
- Harmonic Minor – classical, dramatic
- Melodic Minor – smooth, jazzy
- Pentatonic Major/Minor – folk-like, bluesy
- Blues – quintessentially bluesy
- Chromatic – all 12 notes
📊 What You’ll See:
For scale A dorian
:
🎵 A DORIAN SCALE
==================================================
📝 Notes: A - B - C - D - E - F# - G
🔢 Intervals: R - 2 - b3 - 4 - 5 - 6 - b7
📊 Scale Degrees:
1st degree: A (R)
2nd degree: B (2)
3rd degree: C (b3)
4th degree: D (4)
5th degree: E (5)
6th degree: F# (6)
7th degree: G (b7)
💡 Character: Natural minor with raised 6th - jazzy, sophisticated
🔗 Related Modes (same notes, different starting points):
G Ionian
→ A Dorian (current)
B Phrygian
C Lydian
D Mixolydian
E Aeolian
F# Locrian
🎼 Common Chords in A Dorian:
1. Am
2. Bdim
3. C
4. Dm
5. Em
6. F#dim
7. G
🌟 Special Features:
- Related Modes: Shows all modes using the same notes
- Character Descriptions: Explains the mood/feel of each scale
- Chord Suggestions: Shows common chords built from scale degrees
- Complete Interval Analysis: Both semitone numbers and musical names
🎯 Try These:
scale C lydian
– Major with raised 4thscale E phrygian
– Minor with lowered 2ndscale G mixolydian
– Major with lowered 7thscale D pentatonic minor
– 5-note blues scale
The error should now be completely fixed, and you have a comprehensive scale reference system with all the modes!
Keeping count, that’s iteration 6. The Python program is 1409 lines long – scarcely a tiny code base, and certainly one that I would normally distribute across many files (libraries and individual classes). Presumably it is straightforward to refactor the code into a more humanly manageable form (?).
One Additional Fix (for Now!)
Damn it, the same error persisted – the chords command was still returning null!
Making things more complex, I’d reached the limit of my conversation. It seems that the free tier enforces a restricted number of exchanges in any given conversation.
Opened a new conversation and researched the error. Then I made another enquiry, providing my full Python script as an attachment: Can you please debug the following code. It provides the following error when I try to access the chords command for the key of C major: Error generating chords for C major: ‘NoneType’ object is not subscriptable
Claude responded: Looking at your code, I found the issue! The problem is in the get_all_chords_in_key
method. It’s missing a return
statement at the end, so it returns None
instead of the chords
dictionary. When print_all_chords_in_key
tries to access this None
value with dictionary keys, it causes the “NoneType object is not subscriptable” error.
All I had to do was look for the relevant method and add the return statement (return chords). A very simple fix.
Now everything appears to be working. Yay!
Spoke too Soon
Of course, there were lingering errors – mainly just very simple, all too human stuff like forgetting to include return statements at the end of methods that needed to return something. However, there were also a couple of more serious logical errors linked to the calculation of chord inversions and intervals, but these seem to have all been fixed in the most recent iteration (7). The latter was completed, thankfully, at the limit of my second development conversation. I can see that you use up your ‘free quota’ very quickly as soon as you write, revise and elaborate longer bodies of code. In the free tier it may work better to develop code projects in a less holistic way, focusing on key and compartmentalised features rather than trying to do everything at once – but that slows things down and is less fun.
In any case, despite saying that I wouldn’t provide the code, below is version 7 of Finish That Song and a guide that provides instructions and summarises program output.
Sorry, discovered that I couldn’t add either a ‘py’ or plain text file as an attachment in Worpress, so I have copied the whole script into Word. You need to open it in Word then ‘save as’ plain text in UTF-8 format and subsequently change the file extension to ‘py’. That works for me.