agentleFS
bnaylorbnaylor/agent_skills/ubuntu-janitor/SKILL.md

ubuntu-janitor

Skill4 starsChanged 5 months agoMITView on GitHub

Remotely maintains and upgrades Ubuntu systems via SSH. Handles apt updates, upgrades, kernel patches, and safe reboots across multiple nodes. Use when you need to synchronize OS versions or apply security patches to a fleet of Ubuntu servers.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 2 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Verification: Verify SSH connectivity and sudo privileges on all nodes.

    line 20
  2. Very specific:

    Update Check: Run sudo apt-get update to refresh package lists.

    line 24
  3. Very specific:

    Reboot Status: Check if a reboot is already pending (/var/run/reboot-required).

    line 26
  4. Very specific:

    Disk Space: Verify sufficient disk space in / and /boot.

    line 27
  5. Very specific:

    If /var/run/reboot-required exists or a kernel was updated, initiate sudo reboot.

    line 40
  6. Distinctive:

    Wait for the node to become reachable again via SSH.

    line 41
  7. Distinctive:

    Mandatory Health Check: Verify system health (uptime, essential services like microk8s/docker, and disk space).

    line 42
  8. Very specific:

    When managing systemd services in a user scope (--user) over SSH, native credential loading via LoadCredentialEncrypted often fails with …

    line 50
  9. Very specific:

    Manual Decrypt: Use ExecStartPre to decrypt the secret manually using systemd-creds decrypt.

    line 54
  10. Very specific:

    Ephemeral Storage: Write the decrypted value to a temporary, RAM-backed environment file (e.g., in /run/user/UID/ or a dedicated runtime …

    line 55
  11. Very specific:

    Environment Injection: Use EnvironmentFile= to load the variables from the temporary file.

    line 56
  12. Very specific:

    Kernel Checks: Always check for reboot-required after a dist-upgrade.

    line 68

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Ubuntu Janitor

This skill automates the maintenance of Ubuntu servers, focusing on safe package updates and system reboots.

Prerequisites

  • SSH access to the target nodes.
  • Passwordless sudo or SSH key-based authentication for the user.
  • Target systems must be running Ubuntu/Debian-based distributions.

Core Workflows

1. Host Discovery & Connectivity

  • Input: Accept a list of hostnames, IPs, or a CIDR range.
  • Verification: Verify SSH connectivity and sudo privileges on all nodes.
  • OS Check: Confirm the OS is Ubuntu/Debian.

2. Audit & Pre-flight

  • Update Check: Run sudo apt-get update to refresh package lists.
  • Pending Updates: Identify packages that will be upgraded or installed.
  • Reboot Status: Check if a reboot is already pending (/var/run/reboot-required).
  • Disk Space: Verify sufficient disk space in / and /boot.

3. Execution (The Maintenance Window)

For each node (or in parallel if requested):

  1. Package Upgrade:
    • sudo apt-get update
    • sudo apt-get upgrade -y
    • sudo apt-get dist-upgrade -y (optional, for kernel/major updates)
  2. Cleanup:
    • sudo apt-get autoremove -y
    • sudo apt-get clean
  3. Reboot Management:
    • If /var/run/reboot-required exists or a kernel was updated, initiate sudo reboot.
    • Wait for the node to become reachable again via SSH.
    • Mandatory Health Check: Verify system health (uptime, essential services like microk8s/docker, and disk space).

4. Verification

  • Confirm all nodes are on the latest available versions.
  • Report any nodes that failed to update or reboot.

User-Scope Systemd Secrets

When managing systemd services in a user scope (--user) over SSH, native credential loading via LoadCredentialEncrypted often fails with "State not recoverable" due to Polkit/session isolation.

The Decryption-Bridge Pattern

To reliably inject encrypted secrets into user services:

  1. Manual Decrypt: Use ExecStartPre to decrypt the secret manually using systemd-creds decrypt.
  2. Ephemeral Storage: Write the decrypted value to a temporary, RAM-backed environment file (e.g., in /run/user/UID/ or a dedicated runtime directory).
  3. Environment Injection: Use EnvironmentFile= to load the variables from the temporary file.

Example:

[Service]
ExecStartPre=/usr/bin/sh -c 'systemd-creds decrypt /path/to/secret.cred > /path/to/runtime/env'
EnvironmentFile=/path/to/runtime/env
ExecStart=/usr/bin/your-app

Best Practices

  • Sequential Updates: For clusters (like K8s), update nodes one at a time.
  • Kernel Checks: Always check for reboot-required after a dist-upgrade.
  • Locking: Be aware of flock or apt locks; wait or report if the frontend is locked.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.