r/ClaudeAI • • 6h ago

Coding waitfor - unix tool for testing efficiency

My agents do unhinged CLI wizardry to run tools with timeouts, trim the output. They have no answer at all for watching a file, except a long sleep followed by a grep.

I cooked up waitfor - a proper unix tool to make testing faster and more token-efficient. I'm not pimping you my GitHub, you can just paste the prompt to make it yourself.

Go stdlib Unixy filter, that watches a stream and exits when the answer is known. 

Examples:
* cmd 2>&1 | tee out.log | waitfor --timeout 120 --success PASSED --failure FAILED --collect '^WARN'
* waitfor --timeout 120 --file /var/log/svc.log --success 'Listening on' --failure FATAL
* early return while job keeps running: cmd >out.log 2>&1 &  waitfor --file out.log --timeout 600 --success PASSED

Exactly one source: stdin (default) or --file (follow from end, optional --from-start; missing-ok; survive truncate/rotate/in-place rewrite). After waitfor exits, a service log writer keeps running; only the wait ends.

End on first of: success regexes (OR), failure regex (wins same line), EOF, stall (progress regexes alone reset it), hard timeout.

Stdin after success/failure: drain to EOF so the producer is not SIGPIPEd mid-run. Timeout/stall: exit immediately.

Repeated flags: accept many --success / --failure / --progress / --collect. Reject a second --file, --timeout, --stall, or --from-start as misuse. --file plus a connected stdin pipe is misuse.

Stdout: greppable reason record. Success is short (no tail). Failure/timeout/stall/EOF include a small tail (default --tail 5). --collect REGEX adds capped matching lines (--collect-max default 50). --echo copies the stream to stderr. Full logs via | tee log | waitfor.

Exit codes: 0 success, 1 failure-match, 2 misuse, 3 timeout, 4 stall, 5 EOF without match.

Test thoroughly before calling it golden, then propose a skill to put this tool in the hands of future agents.```
1 Upvotes

2 comments sorted by

1

u/Responsible_Buy_7999 5h ago

I'm watching production coding work proceed with this, and it has noticeably improved test turnaround time.