Single file Python CLIs when do you split, when do you keep it monolithic?

Posted by Beneficial_String411@reddit | Python | View on Reddit | 44 comments

Working on a tool that's grown to \~4000 LOC in one .py file. argparse + 18 subcommands, stdlib + pyyaml only. Tests are in a separate dir.

Single-file has been great for:

- Debugging (one file to grep)

- Distribution (one wheel, no package layout decisions)

- Onboarding contributors

But I'm starting to wonder if it's worth keeping monolithic at this size. What's your threshold for splitting? Is it LOC, or coupling, or "I can't navigate it anymore"?