Hermes self-improving skill: cách agent học từ việc đã làm + share skills

Chia sẻ bài viết

Mục lục
Minh hoạ Hermes self-improving skill học từ việc đã làm

Slogan của Hermes Agent là "The agent that grows with you" - không phải marketing. Khi bạn ngồi với Hermes 1 tuần, nó bắt đầu biết style code của bạn, quen với workflow của bạn, không hỏi lại những câu đã hỏi. Cơ chế đằng sau là skill system: agent tự viết file Markdown mỗi khi giải xong một task khó, lần sau gặp lại nó đọc skill và làm nhanh hơn. Bài này phẫu thuật skill system, agentskills.io standard, và cách share skill cộng đồng.

Vấn đề các agent thông thường: "amnesia loop"

Bạn đã từng chat với ChatGPT/Claude qua API và phát hiện ra ngày mai nó không nhớ ngày hôm qua. Cùng task, nó hỏi lại cùng câu, đi lại cùng dead-end. Đây gọi là amnesia - mất trí nhớ giữa các session.

Một số solution thông thường:

  • Long context: nhét tất cả history vào prompt. Tốn token nhanh, vẫn không scale.
  • Vector memory (RAG): lưu fact, retrieve khi cần. Tốt cho fact, kém cho procedure (cách làm).
  • Fine-tuning: retrain model với data riêng. Đắt, chậm, không update nhanh được.

Hermes chọn cách khác: skill memory. Mỗi lần agent giải xong một task mà nó cảm thấy "đáng nhớ", nó viết file Markdown ngắn (200-500 từ) mô tả cách giải. File lưu tại ~/.hermes/skills/. Lần sau gặp task tương tự, agent đọc skill trước khi bắt đầu, dùng làm runbook.

Khi nào agent tự viết skill

Hermes không viết skill mỗi task - sẽ ngập file. Có 4 trigger được tài liệu mô tả:

  1. Task gọi >= 5 tool call: nghĩa là task không trivial, đáng note pattern
  2. Agent gặp lỗi và recover thành công: bài học từ lỗi đáng lưu
  3. User correct agent một bước: user dạy = phải nhớ
  4. Workflow non-obvious đã work: cách làm sáng tạo cần preserve

Khi một trong những điều kiện trên xảy ra và task complete, agent self-evaluate: "có nên skill hóa không?". Nếu yes, nó tạo skill file. Tên skill tự descriptive (ví dụ setup-pg-replica.md, scrape-tiktok-shop.md), nội dung structured.

Cấu trúc một skill file

Skill follow agentskills.io standard - format Markdown đơn giản, cross-compatible với Claude Code, Cursor, Codex CLI, Gemini CLI. Ví dụ một skill thật từ agent của mình:

---
name: setup-postgres-replica-streaming
description: Cấu hình streaming replication cho PostgreSQL primary + 1 replica trên 2 VPS Ubuntu.
tags: [postgres, devops, ha]
created: 2026-04-12
updated: 2026-05-21
---

# Setup Postgres streaming replica

## Pre-conditions
- Primary và replica đều Ubuntu 22.04, PG 16
- 2 VPS thấy nhau qua private network hoặc tunnel
- User có sudo

## Bước
1. Trên primary:
   - Edit postgresql.conf: wal_level=replica, max_wal_senders=10
   - Edit pg_hba.conf: add replication user
   - Restart pg
2. Trên replica:
   - Stop pg service
   - rm -rf data dir
   - pg_basebackup -h primary -U replicator -D /var/lib/postgresql/16/main
   - Start pg
3. Verify: \x replication state

## Lưu ý đã học
- pg_basebackup phải chạy bằng user postgres, không phải root
- Nếu firewall block port 5432, sửa ufw trước khi basebackup
- Lần đầu mình quên set listen_addresses='*' trên primary - mất 30 phút debug

## Related skills
- backup-postgres-daily.md
- monitor-pg-replication-lag.md

Notice frontmatter YAML - chuẩn agentskills.io. Bất kỳ agent compatible nào (Hermes, Claude Code, Cursor...) đều parse được.

Cách skill được active trong session

Khi bạn ra task mới, Hermes làm:

  1. Search ~/.hermes/skills/ + skill embedded trong project
  2. Embedding-match task description với skill name + description
  3. Load top-K relevant skill vào system context
  4. Plan task có tham chiếu skill
  5. Execute, có thể update skill nếu phát hiện improvement

Cơ chế này khác RAG truyền thống: không retrieve fact, mà retrieve procedure. Agent đọc skill như đọc runbook của senior engineer để lại. Effect: task mới-tương-tự được giải nhanh hơn 3-5x lần sau.

Real example: skill improve qua 1 tuần

Mình theo dõi skill scrape-shopee-product.md trong 7 ngày:

NgàyTriggerSkill thêm gì
1Lần đầu cào Shopee, mất 12 tool callSkill viết: selector .title, .price, cần proxy VN, user-agent mobile
2Captcha xuất hiệnSkill update: detect captcha, sleep 30s, switch proxy, retry max 3 lần
3Mình correct agent: nên dùng tab Reviews thay vì tab defaultSkill update: section "click tab Reviews trước khi parse review"
4Run mượtKhông update
5Site change layout, selector .price không workSkill update: fallback selectors [".price", "[data-testid=price]", ".item-price"]
6Mình thêm task: cũng cào shipping infoSkill thêm section "scrape shipping fee"
7Run rất nhanh, 4 tool call thay vì 12Skill polish: cleanup, sort step, update example

Sau 7 ngày, skill scrape-shopee-product.md dài ~400 dòng, chứa tất cả edge case đã gặp. Agent giải task mới trong category này gần như instant.

💡 Mẹo: Vào ~/.hermes/skills/ đọc trực tiếp. Bạn sẽ ngạc nhiên agent đã học gì. Đây cũng là cách audit: nếu skill có info sai/lỗi thời, sửa tay - lần sau agent dùng version bạn sửa.

Browse + install skill cộng đồng qua agentskills.io

Vì skill là Markdown chuẩn, repo skill cộng đồng dễ tạo. agentskills.io là registry mở (theo doc Nous), bạn có thể:

  1. Browse skill theo category (devops, scraping, content, finance...)
  2. Install skill vào Hermes của mình
  3. Contribute skill của bạn lên

Command install (subject thay đổi - check doc chính thức):

hermes skill install username/skill-name
hermes skill list
hermes skill remove username/skill-name

Có một repo cộng đồng awesome-hermes-agent (GitHub) liệt kê skill chất lượng. Ví dụ skill mình hay dùng:

  • devops/deploy-nextjs-vps.md - deploy Next.js app lên Ubuntu VPS với pm2, nginx, certbot
  • content/seo-meta-generator.md - generate meta title, meta desc theo SEO best practice
  • scraping/anti-captcha-rotation.md - pattern xử lý captcha với proxy rotate + sleep
  • finance/parse-bank-statement.md - parse sao kê ngân hàng VN sang Excel

Khi install xong, agent của bạn lập tức biết những workflow đó. Đây là collective intelligence: bạn không cần dạy lại agent những gì người khác đã dạy.

Version, share, tự build skill

Skill là file Markdown, nên git là tool tự nhiên. Mình giữ skill riêng trong repo git private:

cd ~/.hermes/skills
git init
git remote add origin [email protected]:myuser/my-hermes-skills.git
git add . && git commit -m "Initial skills"
git push -u origin main

Trên VPS khác cài Hermes mới, chỉ cần clone repo vào ~/.hermes/skills/ là có ngay tất cả skill đã train.

Khi muốn share một skill cho cộng đồng, tách ra repo public, theo format agentskills.io, submit lên registry. Format checklist:

  • Frontmatter có name, description, tags
  • Section bước rõ ràng
  • Khai báo dependency (tool nào cần, env variable nào)
  • Edge case đã handle
  • Example use case
⚠️ Lưu ý: Skill có thể chứa credential nhạy cảm nếu agent tự note. Trước khi push public, dùng git diff review, dùng git-secrets hoặc trufflehog scan. Không bao giờ push skill có API key, password, internal URL trong example.

Skill chained: pattern advanced

Agent có thể trong skill A reference skill B. Ví dụ:

# Skill: weekly-product-research-pipeline

## Bước
1. Run skill `discover-trending-products`
2. Run skill `validate-product` với output bước 1
3. Với mỗi product validated:
   - Run skill `scrape-shopee-product`
   - Run skill `compose-affiliate-article`
   - Run skill `publish-wordpress`
4. Báo cáo

Skill cha gọi skill con. Hermes runtime resolve chain, có thể spawn subagent cho từng nhánh parallel. Đây là cách bạn build "agent capability" qua hợp thành từ skill nhỏ.

So với memory của các agent khác

AgentMemory typePersistenceShareable
HermesSkill markdown + SQLite conversationFile localYes (agentskills.io)
Claude CodeCLAUDE.md + skills (compat)File localYes (compatible)
CursorRules .mdc + memoryFile localPartial
ChatGPT custom GPTInstructions + Knowledge filesCloud (OpenAI)Limited
Auto-GPT cũVector memoryDBNo standard

Lợi thế Hermes: skill là Markdown human-readable, version qua git, cross-agent compatible. Bạn không bị lock-in.

Pitfall: skill conflict, skill stale

Sau 2-3 tháng tích lũy, mình bắt đầu thấy vấn đề:

  • Skill conflict: hai skill cùng claim handle một task (vd scrape-tiktok-v1.mdscrape-tiktok-v2.md), agent confused chọn cái nào
  • Skill stale: site thay đổi layout, skill cũ chứa selector đã chết, agent cứ thử rồi fail
  • Skill quá dài: tích lũy edge case 1 năm, file dài 2000 dòng, agent đọc lâu

Cách mình quản lý:

  1. Quarterly review: list skill, xóa skill không dùng > 3 tháng
  2. Khi update skill mới, đặt note "deprecated YYYY-MM-DD" lên skill cũ
  3. Split skill dài thành module nhỏ, link qua "Related skills"
  4. Đặt giới hạn 500 dòng/skill - vượt thì refactor

Skill memory + project memory

Hermes phân biệt:

  • User skill: ~/.hermes/skills/ - applicable mọi project
  • Project skill: ./.hermes/skills/ trong repo - chỉ active khi cwd ở project đó

Pattern phổ biến: skill chung (devops, content, scraping) ở user level. Skill specific cho codebase (style guide team, deployment workflow project) ở project level và commit lên git repo. Onboarding member mới: clone repo, chạy Hermes, agent đã biết workflow của team.

Hạ tầng để skill memory không mất

Skill là file - sống chết theo disk. Mất disk = mất 6 tháng training. Mình áp dụng:

  • Skill dir là git repo, push lên private GitHub mỗi ngày qua cron
  • VPS có snapshot - TND Cloud VPS có snapshot daily, restore 1-click
  • Ceph SSD NVMe replicate built-in, ít rủi ro disk fail
  • RAM ECC tránh corruption file ngẫu nhiên

VPS rẻ không ECC, không snapshot - một sự cố disk mất tất cả skill memory. Đây là một trong những lý do mình stick với TND Cloud VPS cho production agent.

Tổng kết: tại sao đây là feature thay đổi cuộc chơi

Agent không có persistent memory = công cụ thuê hàng ngày. Agent có skill self-improving = đồng nghiệp ngày càng quen với mình. Lần đầu Hermes chỉ là LLM wrapper. Sau 3 tháng dùng, nó là engineer junior đã biết hết quirk của codebase, không hỏi lại câu đã hỏi, tự tránh trap đã sa.

Cộng với agentskills.io standard, bạn không phải dạy lại những gì người khác đã dạy. Skill được tích lũy, share, fork - giống cách open source code đã thay đổi development 20 năm trước, giờ đang xảy ra với agent skill.

Nếu chưa setup Hermes, đọc bài cài Hermes gắn proxy. Chưa chọn VPS, xem pillar VPS cho vibe coder.

Bài viết liên quan

Skill memory cần lưu lâu dài, disk ổn định?

TND Cloud VPS có Ceph SSD NVMe replicate, RAM ECC, snapshot daily - skill agent train trong tháng không mất vì lỗi phần cứng.

Xem bảng giá VPS

2009
15+ năm vận hành liên tục
10+
tập đoàn lớn tin dùng
100+
doanh nghiệp SMB Việt
30 ngày
đổi key lỗi miễn phí
Phần mềm bản quyền chính hãng chúng tôi cung cấp
Bản quyền chính hãng Hóa đơn VAT đầy đủ Đổi key lỗi 30 ngày Vận hành từ 2009 MST 0200994870 Hotline 0225.999.6666