--- name: scheduled-command-automation description: "Use when scheduling local commands. Verify delivery." license: MIT author: HamaratLabs version: 1.0.0 --- # Scheduled Command Automation Use this skill for recurring local scripts whose stdout should be delivered to the user's channel, especially unattended nightly jobs. ## Procedure 1. **Confirm the command and delivery semantics.** Preserve the command exactly as provided. Treat an empty stdout result as a successful silent run; non-zero exit or timeout should remain visible as an error. 2. **Choose script-only cron when the output is fully determined by the command.** Create the job with `no_agent=True`, a recurring cron expression, the script filename, and `deliver="origin"` when the requested destination is the current home channel. This removes the scheduler's additional agent pass and delivers stdout verbatim; it does not eliminate inference costs when the script itself launches agent CLIs. 3. **If the scheduler requires an allowed script root, create a thin wrapper inside `$HERMES_HOME/scripts/`.** The wrapper must invoke the requested command without changing its arguments, forward stdout and stderr, and return the child exit code. Pass only the relative wrapper filename to the cron tool; absolute paths are rejected even when they point inside the allowed directory. 4. **Use the requested timezone explicitly when the scheduler supports it.** If the cron interface has no timezone field, verify the host offset before creating the job and report the resulting offset with the next-run timestamp rather than silently assuming a timezone. 5. **Create the job through the cron management tool, not by editing scheduler storage directly.** Set a human-readable name, recurring schedule, delivery target, `no_agent=True`, and the wrapper script. Do not add a prompt because script-only jobs ignore it. 6. **Read the job back after creation or repair.** Verify the exact job, schedule, script and delivery target. For a repair, first reproduce the failing stage under the service environment, then exercise that stage against an existing authorized input. This proves only the stage, not the complete job. When a full rerun is requested, check `hermes cron run --help`, run `hermes cron run ` without weakening approvals, then use `hermes cron list` to confirm a new `ok`/`completed` execution and inspect its output artifact. Do not edit historical failure counters to make the job appear healthy. 7. **Report execution, coverage and delivery separately.** A completed script may contain child timeouts or startup failures; a generated analysis may still misclassify their severity. Count child results from the raw records, label no-work replies separately from empty replies, and treat model incident summaries as unverified until checked. Give a concise result: what changed, what actually passed, remaining child failures, and next scheduled run. Do not claim message delivery from script success alone. ## Recovering a broken rclone bisync baseline When an Obsidian vault is synchronized by `rclone bisync` and the prior Path1/Path2 listings are missing, do not run a blind `--resync`. 1. Run a read-only inventory with `rclone check --size-only` and capture `--combined` output; classify remote-only, local-only, and differing files. 2. Back up remote-only and differing remote versions to a temporary recovery directory before reconciling, because resync changes the remote state. 3. Preview the recovery with the vault as Path1 and `--resync --resync-mode path1 --dry-run --max-delete 5` using the mandatory excludes: your private folders (e.g. `/**`), `.obsidian/**`, `.DS_Store`. 4. If the dry-run shows only the intended transfers and no unsafe deletions, run the same command without `--dry-run`. 5. Verify with `rclone check --size-only` and a normal `rclone bisync --dry-run`; require zero differences and zero planned transfers before declaring recovery complete. 6. **Test the actual scheduled sync path once, then leave the recurring job on normal bisync without resync.** Use `--resync-mode path1` only when the local vault is the declared source of truth; never infer the winner from whichever side happens to be newer. Keep `--max-delete` enabled so an unexpected deletion plan aborts instead of propagating silently. For a user request such as “just sync,” execute the smallest verified sync workflow and report only the outcome, error, and verification; do not narrate internal approval or security-tool mechanics. ### Mobile Google Drive Sync push/pull safety When a phone Obsidian plugin shows a note as blank, `Create`, or `Delete` during Push, do not push first. Pull from Drive, reopen the note, and confirm its body is present; a mobile placeholder can upload as a zero-byte duplicate and overwrite or confuse the full copy. If a push has already created duplicate remote names, inspect the exact objects with `rclone lsjson` and compare `Size`/`ID`; `rclone size` alone can hide duplicates by aggregating or selecting one object. Preserve the nonzero object, preview deletion of only the zero-byte object with `rclone deletefile --dry-run`, delete that exact path only after the preview targets size 0, then verify one remaining object, `rclone cat` content, and `rclone check --size-only`. Treat an unexpected mobile `Delete` separately from intended deletions: remove only the intended deletion from the queue, and cancel the whole Push when the note body has not been pulled yet. ## Obsidian vaults synced by Google Drive Sync When the command writes inside an Obsidian vault using the `google-drive-sync` community plugin, do not assume that an Obsidian command URI or a headless terminal wrapper performs a completed pull/push. First verify a supported non-interactive sync interface; otherwise keep the cron wrapper limited to the local write, respect the user's **Automatically push changes** preference, and report that Drive synchronization remains a manual Obsidian action. Do not fail the research command merely because a local sync marker did not change: an unchanged marker is not proof that the write failed. ## Always-on pitfalls - A paused job cannot be fired: the run action returns `Job is paused/disabled; resume it before running` and performs nothing. To pilot a not-yet-trusted job, resume it, run it, then pause it again immediately so the recurring schedule stays off while acceptance is pending. - Build the job and pilot it in the same session, then show the user the real output. A described contract, schedule and filter set with no executed run is not a delivered automation, and presenting it as a finished system invites a justified rejection. - Separate the user's task-level request from a tool's execution-approval gate. If a tool reports `BLOCKED`/`not run`, state that the command never executed and name the actual gate; do not imply the task request was unclear or ask the user to re-approve its content. Honor an explicit do-not-retry denial and never route around it through another tool. - Restarting the gateway (`hermes gateway start`) kills the process serving the current conversation, so an in-flight tool call is cut and the session reconnects afterwards. Treat it as a side-effecting action: announce it, and after the reconnect verify with `hermes gateway status` instead of re-running the restart. - When asked to "activate whichever inactive jobs can be activated", classify each `[paused]` job before touching it: (a) broken but fixable — reproduce by running its script once in the background (multi-profile scripts take several minutes), read the real error in the raw output (stale model id, push already resolved, bad flag), fix the cause, re-run end to end, then `cronjob_manage resume`; (b) paused by design awaiting the user's acceptance of a pilot (the skill that built it says "create paused, pilot, then enable") — leave it and say so; (c) its script conflicts with a standing red line (e.g. blanket `--dangerously-skip-permissions`) — fix the script with the user's go-ahead and leave the final activation to the user if they said they would do it. After `resume`, a stale `next_run_at` in the readback is cosmetic; verify `enabled: true` / `state: scheduled`. - A cron/script that commits and pushes to a specific git branch (e.g. to auto-publish generated data) must run against a worktree PERMANENTLY checked out on that target branch, never a project's primary/shared checkout — that checkout gets switched to arbitrary feature branches by other work throughout the day, so a scheduled commit can silently land on the wrong branch and never reach the pushed target. Maintain (or create once) a dedicated worktree pinned to the target branch for this purpose, and have the script `fetch`+`pull --ff-only` it before writing, to stay in sync with manual pushes made elsewhere. - **macOS LaunchAgents for project jobs and boot daemons cannot be loaded from inside the agent's own gateway/service process** (it is guarded to prevent restart loops; never switch verbs or tools to get around it). Validate plists with `plutil -lint`. For autostart daemons (`RunAtLoad: true`) that spawn persistent child processes, set `AbandonProcessGroup` so launchd does not kill child processes when the startup wrapper exits. Make the startup script idempotent (check `lsof -tiTCP: -sTCP:LISTEN` before launching) and network-resilient (loop `curl` against an external host before calling network APIs or tunnels). A LaunchAgent that runs a script under a privacy-protected folder (`~/Desktop`, `~/Documents`, `~/Downloads`) is denied by macOS privacy protection at boot (`Operation not permitted`), so the autostart silently fails after the first reboot. Do not wrap the command to sidestep that protection. Instead either move the script, its working directory and its logs to an unprotected location (e.g. `~/Library/Application Support//` or `~/.local/share//`), or ask the user to grant the needed access themselves in System Settings > Privacy & Security. Add `StartInterval 600` with an early silent `exit 0` when the port already listens, so a crashed server comes back within 10 minutes. After any reboot, check `curl` on the public URL and the startup log before assuming the service is up. To test without rebooting, simulate launchd's clean environment via `env -i HOME=$HOME USER=$USER /bin/bash