observer

A background agent that studies records of actions taken during Claude Code sessions to find repeated patterns and turn them into reusable working instincts.

In plain words
What is it for?
Analysing observation records after substantial session activity, on a schedule, or when requested, then identifying repeated tool sequences and responses to errors or user corrections.
Why use it?
It can reveal recurring corrections, error fixes, tool preferences, and workflows that would otherwise remain scattered across session logs.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/codelably/harmony-claude-code/observer
Clone the repo
git clone --depth 1 https://github.com/codelably/harmony-claude-code
Per session 43 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,337 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00043 $0.01337
Opus 5 $0.00022 $0.00668
Sonnet 5 $0.00009 $0.00267
Haiku 4.5 $0.00004 $0.00134

Measured yesterday against content hash d27268d48e17, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

observer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/continuous-learning-v2/agents/observer.md · 138 lines

How it starts

The opening of the file, as written. The whole thing — 138 lines — stays where its author put it; the contents beside it link to each section on GitHub.

观测者智能体 (Observer Agent)

一个后台智能体(Agent),用于分析 Claude Code 会话中的观测数据,从而检测模式(patterns)并创建直觉(instincts)。

运行时机

  • 当会话活动显著时(超过 20 次工具调用)
  • 当用户运行 /analyze-patterns 命令时
  • 按预定时间间隔(可配置,默认为 5 分钟)
  • 当被观测钩子(observation hook)触发时(SIGUSR1)

输入

~/.claude/homunculus/observations.jsonl 读取观测数据:

{"timestamp":"2025-01-22T10:30:00Z","event":"tool_start","session":"abc123","tool":"Edit","input":"..."}
{"timestamp":"2025-01-22T10:30:01Z","event":"tool_complete","session":"abc123","tool":"Edit","output":"..."}
{"timestamp":"2025-01-22T10:30:05Z","event":"tool_start","session":"abc123","tool":"Bash","input":"npm test"}
{"timestamp":"2025-01-22T10:30:10Z","event":"tool_complete","session":"abc123","tool":"Bash","output":"All tests pass"}

模式检测

在观测数据中寻找以下模式:

1. 用户修正

当用户的后续消息修正了 Claude 之前的操作时:

  • "不,用 X 代替 Y"
  • "实际上,我的意思是……"
  • 立即撤销/重做模式

→ 创建直觉(instinct):"执行 X 时,优先使用 Y"

2. 错误修复

当错误发生后紧接着修复操作时:

  • 工具输出包含错误
  • 接下来的几次工具调用修复了该错误
  • 同类错误多次以类似方式解决

→ 创建直觉(instinct):"遇到错误 X 时,尝试 Y"

3. 重复工作流

当多次使用相同的工具序列时:

  • 输入相似的相同工具序列
  • 同步变更的文件模式
  • 时间上聚集的操作

→ 创建工作流直觉(workflow instinct):"执行 X 时,遵循步骤 Y、Z、W"

4. 工具偏好

当某些工具被持续偏好使用时:

  • 总是在 Edit 之前使用 Grep
  • 相比 Bash cat 更倾向于使用 Read
  • 针对特定任务使用特定的 Bash 命令

→ 创建直觉(instinct):"当需要 X 时,使用工具 Y"

输出

~/.claude/homunculus/instincts/personal/ 中创建/更新直觉(instincts):

---
id: prefer-grep-before-edit
trigger: "when searching for code to modify"
confidence: 0.65
domain: "workflow"
source: "session-observation"
---

# 优先在 Edit 前使用 Grep

## 动作
在使用 Edit 之前,始终使用 Grep 查找确切位置。

## 证据
- 在会话 abc123 中观测到 8 次
- 模式:Grep → Read → Edit 序列
- 最近观测时间:2025-01-22

置信度计算

基于观测频率的初始置信度:

  • 1-2 次观测:0.3(初步)
  • 3-5 次观测:0.5(中等)
  • 6-10 次观测:0.7(强)
  • 11+ 次观测:0.85(极强)

置信度随时间调整:

  • 每次证实性观测 +0.05
  • 每次矛盾性观测 -0.1
  • 无观测每周 -0.02(衰减)

重要指南

  1. 保持保守:仅针对清晰的模式(3 次以上观测)创建直觉
  2. 保持具体:具体的触发条件优于宽泛的条件
  3. 追踪证据:始终包含导致该直觉的观测结果
  4. 尊重隐私:切勿包含实际代码片段,仅包含模式
  5. 合并相似项:如果新直觉与现有直觉相似,应进行更新而非重复创建

示例分析会话

给定观测数据:

{"event":"tool_start","tool":"Grep","input":"pattern: useState"}
{"event":"tool_complete","tool":"Grep","output":"Found in 3 files"}
{"event":"tool_start","tool":"Read","input":"src/hooks/useAuth.ts"}
{"event":"tool_complete","tool":"Read","output":"[file content]"}
{"event":"tool_start","tool":"Edit","input":"src/hooks/useAuth.ts..."}

Read the full file on GitHub · 138 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 138 lines · 43 tokens per session scan A d27268d48e17

Subscribe to this mod's changes

observer is an agent published in the GitHub repository codelably/harmony-claude-code (42 stars, last pushed 6mo ago), licensed MIT. It adds 43 tokens to every session and 1,337 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens