Image of Lucian Ghinda writing for notes.ghinda.com
February 27th, 2025

Trying claude code for the first time with Ruby on Rails

This morning I played a bit with Claude Code and tried it out on a piece of #Ruby that was written in a hurry for a personal project.

I asked the following prompt:

Prompt used for Claude Code

It created a new file that included the previous code and maintained the previous structure with private attr_reader, even though it wasn’t necessary here.

New file created by Claude Code

It then replaced the previous code with a call to the new object.
At least two notes:
- It is not necessary to use require relative since this is a Rails project
- It kept that method with a single call and here, I would have liked to discuss whether to keep it or not

The changes in the existing file

Then it copied the test from the previous big file to this one and added an extra test.
Notice not only here but in multiple files that it does not add new line at the end of the file.

The tests moved to the new file

It then executed the tests and wrote a summary.
I would have liked to have executed the test from the file where the code was extracted to ensure that the tests there still passed. I executed it manually, and it still passed.

Executing tests

The total cost for this operation 29 cents and it took 3 minutes. Well the number of minutes is not real because I stopped multiple times taking screenshots.

Total costs