The more you use an AI agent, the more valuable it becomes. You customize its personality, add skills, teach it how you work, and build up memory and context. If the machine running it fails, rebuilding all of that from scratch would be painful.
A practical safety net is to back up the files that make your agent personal into a private GitHub repository — while carefully keeping secrets, tokens, and credentials out of it.
⚡ The golden rule: back up the agent’s identity, not the keys to your accounts. A private repo is a backup location, not a password vault.
🗂️ What to back up
The goal is simple: (your personalized agent) − (generic install) − (secrets). Concretely, that usually means:
- ⚙️ Configuration files — Model, provider, personality, terminal preferences, and other agent-level settings.
- 👤 Personality / instructions — The role, tone, and rules that define how your agent behaves and responds.
- 🧠 Memory files — Long-term context and preferences — review carefully for personal info first.
- ⏰ Scheduled tasks — Cron jobs and recurring automations that are easy to forget during a rebuild.
- ✨ Custom skills — Scripts and workflows you created or modified for your specific needs.
- 🚫 Never include — Secrets, tokens, credentials — these must never go into the repo.
🚫 What never belongs in the repo
.envfiles- API keys and access tokens
- OAuth and authentication files
- Private URLs, chat IDs, or other sensitive identifiers
🚀 The backup workflow
1. Create a private GitHub repository
Create a new repo dedicated to the backup and set visibility to Private. Initialize it empty — no README, no .gitignore, no license — so the agent can set it up cleanly.
2. Generate a fine-grained access token
In GitHub, go to Settings → Developer settings → Personal access tokens → Fine-grained tokens. Restrict it to the backup repository only, with Contents: Read and write permission. Set an expiration date if you can — a leaked token with an expiry does far less damage.
3. Store the token securely
Copy the token into a password manager. Never paste it into files that will be committed. If it is ever exposed, revoke it in GitHub immediately and generate a replacement.
4. Connect the agent
Add the token through your agent’s configuration so it is stored as a secret, not inside the files you plan to back up. For example:
agent config set GITHUB_TOKEN <your-token>
5. Run the first backup manually
Ask the agent to commit the configuration, memory, skills, and scheduling files. Then open the repo and review every committed file — confirm that no keys, tokens, or private notes slipped in.
6. Automate recurring backups
Once the first backup is clean, schedule a daily job and a notification after each run. Keep reviewing occasionally: automation is helpful, but it should not be blind.
💭 Final thoughts
A personalized AI agent becomes hard to replace once it holds your settings, memory, and workflows. A clean private GitHub backup gives you a restore path when hardware fails or you migrate machines — without turning GitHub into a secrets manager.
Inspired by a guide from Zawanah about backing up a Hermes agent to GitHub.