r/androiddev • • 9d ago

Tips and Information tiny .aiignore and pre-warmed git worktree setup that stopped parallel coding agents from triggering 4-minute cold gradle syncs on our laptop

Post image

running 2 or 3 coding agents in parallel sounds great until i really tried it on a multi-module gradle repo. say, put them in one checkout and they immediately fight over build.gradle and lock .git/index.lock. create a fresh git worktree per task and gradle eats four minutes re-indexing dependencies while spawning four daemons that chew through 16gb of ram.

here is the tiny workflow cleanup that finally made parallel agents usable on gradle without melting my prescious laptop:

  1. keep exactly two permanent sibling worktrees checked out next to main (e.g. ../repo-wt-1 and ../repo-wt-2) instead of creating and deleting fresh folders per ticket. resetting a warm worktree to a new branch preserves local gradle build outputs and avoids cold syncs.
  2. drop a strict .aiignore in the repo root blocking build/, .gradle/, generated protobuf/kapt folders, and huge fixture dumps so agents stop burning context reading compiled artifacts.
  3. cap parallel daemons in ~/.gradle/gradle.properties (org.gradle.workers.max and shared build cache enabled) and keep agent sessions isolated via /worktree or an ide manager like jetbrains air where real intellij inspections verify the diff afterward

nothing fancy, just stopped parallel agent runs from turning into fan noise and merge soup. any other gradle-specific flags folks here set when running multiple local coding agents?

4 Upvotes

2 comments sorted by

1

u/meVoyager 8d ago

are both worktrees on the same gradle version? i’d check `./gradlew --status` in each.

-1

u/Evening_Hawk_7470 9d ago edited 3d ago

fun! reusing two permanent sibling worktrees instead of spinning up a fresh one per ticket is the single biggest gradle speedup, agreed. i use junie cli for the parallel part and really like its /worktree isolation for exactly this: each agent stays in its own worktree, so together with the .aiignore the build caches stay warm and nothing collides on index.lock. the runs go in the background and i check on them from my phone.