Featured blog post image of a Bash script in action, highlighting the use of automated linters for enhanced coding practices and learning.

Welcome to another insightful edition of TWIL, where we distill our journey through code into weekly packets of learning. This week features Katie's breakthrough with a bash function that streamlines running code linters like ruff on file batches, transforming the git commit preparation from a chore into a learning opportunity.

Batch ruff --fix by git status

I made a bash function to let me run ruff --fix on batches of files based on git status (or on all changed files) at once; for example, when I go to commit changes and the pre-commit-hook ruff tells me i've missed some things, instead of running ruff --fix for each affected file, I can now do ruff-fix A to run it for the files I've got staged for commit (which then also lets me review those diffs versus what I've got staged, so I can learn from the changes ruff makes, too).

# ruff --fix changed files all at once

ruff-fix()
{
  # Fix files with staged changes
  if [[ $1 = "staged" ]] || [[ $1 = "added" ]] || [[ $1 = "A" ]]; then
    GIT_STATE="A"
  # Fix files with unstaged changes
  elif [[ $1 = "unstaged" ]] || [[ $1 = "unadded" ]] || [[ $1 = "modified" ]] || [[ $1 = "M" ]]; then
    GIT_STATE="M"
  # Fix untracked files
  elif [[ $1 = "untracked" ]] || [[ $1 = "new" ]] || [[ $1 = "U" ]] || [[ $1 = "??" ]]; then
    GIT_STATE="??"
  # Fix all modified files (staged/unstaged/untracked/whatever)
  else
    GIT_STATE="."
  fi

  git status -s | grep "$GIT_STATE" | cut -c 4- | xargs ruff --fix
}
  • Bash
  • git
Katie Linero's profile picture
Katie Linero

Senior Software Engineer

Related Posts

AWS logo centered over dark blue stylized map of Europe with concentric radar-style rings emanating from Germany, representing the AWS European Sovereign Cloud infrastructure launch for EU data sovereignty and GDPR compliance
January 26, 2026 • Frank Valcarcel

AWS Launches European Sovereign Cloud

AWS launched a physically separate cloud infrastructure in Europe with EU-only governance, zero US dependencies, and over 90 services. Here is what organizations in healthcare, finance, and government need to know about the sovereign cloud and how to evaluate it for their compliance strategy.

Blueprint-style architecture diagram of an AI agent framework showing the core orchestration loop of observe, think, act, and repeat, with components for planning, state management, LLM reasoning, tool execution, and persistent memory connected by directional data flows on a dark grid background.
March 27, 2025 • Frank Valcarcel

A Practical Guide to Agent Orchestration Frameworks

There are at least a dozen frameworks competing to be the foundation for your agent architecture. This post breaks down how each one thinks about the problem, where it shines, and where it will cost you time. We are not ranking them. The right choice depends on your use case.

Let's work together

Tell us about your project and how Cuttlesoft can help. Schedule a consultation with one of our experts today.

Contact Us