git-agent for RubyConventional commits for Ruby and Rails projects
git-agent understands Rails MVC conventions, Active Record migrations, and Gemfile dependency changes, splitting your working-tree changes into clean atomic commits with conventional messages.
diff example
diff --git a/app/services/invoice_generator.rb b/app/services/invoice_generator.rb
index 9a2c4f1..3b7d8e5 100644
--- a/app/services/invoice_generator.rb
+++ b/app/services/invoice_generator.rb
@@ -1,14 +1,26 @@
class InvoiceGenerator
def initialize(order)
@order = order
end
- def call
- Invoice.create!(
+ def call
+ raise ArgumentError, "order must be completed" unless @order.completed?
+
+ ActiveRecord::Base.transaction do
+ invoice = Invoice.create!(
number: generate_number,
order: @order,
- total: @order.total
- )
+ total: @order.total,
+ tax: calculate_tax(@order.total),
+ issued_at: Time.current
+ )
+ @order.update!(invoiced: true)
+ invoice
+ end
end
+ private
+
+ def calculate_tax(amount)
+ (amount * TaxRate.current).round(2)
+ end
endgit-agent output
feat(invoice): wrap generation in transaction and add tax calculation
- guard against invoicing incomplete orders with ArgumentError
- wrap Invoice.create! and order status update in a transaction for atomicity
- extract calculate_tax private method using current TaxRate record
- add issued_at and tax fields to the created invoice
Previously a failed order status update would leave an invoice without
marking the order as invoiced; the transaction ensures both records are
consistent or neither is written.Why it works for Ruby
- Recognises Rails MVC structure (models, controllers, views, services) for scope naming
- Separates Active Record migration files into dedicated db commits
- Groups Gemfile and Gemfile.lock changes into chore(deps) commits
- Works with RSpec and Minitest test file conventions
install
brew install gitagenthq/brew/git-agent
# inside your Ruby project
git-agent init # detects Rails app structure and suggests scopesFAQ
Does git-agent handle Rails migration files separately from model changes?Yes. Files in db/migrate/ are always treated as a separate commit with a db or chore scope, keeping migration history distinct from application logic.
Can git-agent work with non-Rails Ruby projects?Yes. Sinatra, Hanami, pure Ruby gems, and scripts are all handled correctly. git-agent does not require Rails to be present.
How does git-agent handle Ruby metaprogramming patterns?The LLM understands Ruby's define_method, method_missing, and module inclusion patterns. Metaprogramming changes are described at the intent level rather than the implementation level.