earthly has something like this. it's wonderful.
https://docs.earthly.dev/docs/guides/debugging
there's also https://github.com/ktock/buildg
looks promising thanks!