3 Token Burn From an Infinite Retry Loop: How I Made Claude Refill My Article Queue When It Runs Dry
Back when I was a college student earning ¥100,000 a month, one finished article meant my week was over. Today launchd stocks one every morning at 8:00, and the series that underpins ¥1.2M in monthly revenue hasn't gone dark once. The difference isn't talent or discipline — it's that I built, exactly one time, an environment that refills its own topic queue. Why this setup works When you try to…
When a Claude-generated article queue runs dry, it can cause the article production process to stop altogether. To avoid this, a system was built that integrates a natural language model called Claude to automatically generate new topics when the queue is empty. The key steps in this refill mechanism are:
1. Monitor the topic queue: The script checks the number of topics in the queue using the `jq` command. If the queue is empty (length equals zero), the script moves to the next step.
2. Generate a new topic: When the queue is empty, Claude is invoked locally using the `claude -p` command. The script provides a prompt to Claude with specific requirements for the new topic, such as the title, slug, sources, and thumbnail title. Claude reviews the day's work, including daily briefs and automation scripts, to generate a relevant article topic.
3. Validate and insert the new topic: Claude's generated JSON is validated to ensure it contains the required fields and adheres to the specified format. If the JSON is valid, the new topic is inserted at the head of the queue. If the JSON fails validation, the script exits without adding the new topic.
4. Resume normal operation: Once a new topic is added to the queue, the production script resumes its normal operation of converting topics into articles, generating thumbnails, and publishing the finished article.
By integrating Claude into the article generation process, the system can continuously generate new topics and avoid the downtime that would occur if the queue runs dry. This ensures a steady stream of articles, maintaining the revenue stream and preventing the user from skipping writing days.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.