Start with a decision you can explain
A useful automation starts with a specific repeated decision. In Janitorfin, that decision is whether media qualifies for cleanup under configured retention rules. The interesting work begins after identifying a candidate: making the proposed change understandable, giving people time to react, and coordinating the other systems that manage the same content.
This is the same pattern behind smaller operational tools. Identify the inputs, write down the rule, and name the intended result before adding a scheduler or interface. If the rule cannot be explained in a few sentences, running it unattended will not make it easier to support.
For cleanup, “old” is not enough. Watched and never-watched media have different rules. A protected tag or a favorite can exclude an item. TV decisions also need a scope: an individual episode becoming eligible should not automatically mean an entire season is ready to remove.
Separate the plan from the change
Janitorfin has a preview that evaluates the settings currently shown in the form without changing the pending queue, deleting media, or updating Radarr and Sonarr. That separation makes rule tuning a visible process rather than an experiment on the library.
The following Python example illustrates a much smaller planning step. It returns a reason for each decision and does not modify files or call external services. The age threshold is an example, not a recommended retention policy or Janitorfin's actual evaluator.
def plan_item(item, retention_days):
if item["protected"]:
return {"id": item["id"], "action": "keep",
"reason": "protected"}
if item["days_since_activity"] < retention_days:
return {"id": item["id"], "action": "keep",
"reason": "recent activity"}
return {"id": item["id"], "action": "review",
"reason": "retention threshold reached"}
sample = {"id": "example-01", "protected": False,
"days_since_activity": 120}
print(plan_item(sample, retention_days=90))
# {'id': 'example-01', 'action': 'review',
# 'reason': 'retention threshold reached'}
A production implementation needs validation for missing or invalid inputs. The important property here is that a plan can be inspected and tested independently of the code that applies it.
Make time and state explicit
A preview is a snapshot. A queued operation needs durable state. Janitorfin saves a pending item's identity, when it first qualified, when it last matched, and its deletion deadline. Repeated scans refresh the existing entry without continually moving that deadline forward.
There is a concrete policy consequence: changing the grace-period setting affects newly queued items, but does not rewrite deadlines already saved in the queue. An operator needs to understand both the setting and the state created by earlier runs.
The pending queue implementation makes that distinction visible. A later scan can remove items that no longer qualify. The overdue task uses the stored queue and lightweight protection checks instead of repeating the full evaluation.
Design for partial failure
Two services do not become one transaction just because one script calls both. Janitorfin updates monitoring in an enabled Radarr or Sonarr integration before deleting the corresponding Jellyfin item. If the required monitoring action fails, that item's deletion is skipped.
The reverse failure still matters: monitoring may be updated successfully and the filesystem deletion may then fail. A useful result needs to preserve that distinction instead of reporting a single vague failure. Janitorfin records deletion outcomes and whether the monitoring update succeeded in its execution results.
For another tool, the same question might be whether an account was created before an email failed, or whether a deployment succeeded before a notification timed out. Retrying the whole workflow without understanding those boundaries can repeat a successful step.
A checklist before scheduling
- Repeat runs: does the same input create duplicate work, reset a deadline, or produce a stable result?
- Changed conditions: which rules are checked again immediately before a change, and which depend on an earlier scan?
- Dependency failure: does the tool skip, stop, or continue when another service is unavailable?
- Observability: can an operator distinguish a candidate, a queued item, a skipped action, and a completed action?
- Scope: does a dry run avoid every relevant side effect, including remote monitoring updates?
These checks are more useful than asking whether the script completed without an exception. They describe whether the resulting system state is the one the operator intended.
The goal: less work, clearer outcomes
The value of automation is not the number of scheduled jobs. It is the manual decision that no longer needs constant attention, with enough explanation and control left behind to handle an exception.
Janitorfin provides a concrete example: preview the rule, stage the decision, show it to the people affected, and apply it later with explicit protection and integration behavior. The full case study follows that workflow through the implementation.
