|
2 | 2 |
|
3 | 3 | <br> |
4 | 4 |
|
5 | | -## *Claude Code plugins for people who **REALLY** on that Claude Code* |
| 5 | +## *Claude Code plugins for those with a healthy sense of curiosity* |
6 | 6 |
|
7 | | -### Experiments in Autonomy and Self-Guided Behavior for Coding Agents |
| 7 | +### Experiments in agent autonomy; at the boundaries of human-agent collaboration |
8 | 8 |
|
9 | 9 | --- |
10 | 10 |
|
11 | 11 | ## Background |
12 | 12 |
|
13 | 13 | The plugins in this repo are primarily research-oriented - I'm not providing a framework that promises to cover the whole SDLC so that you can "ship while you sleep". There are plenty of those around, and I suspect part of the reason for that is because a lot of them are quite good. But my approach to working with Claude has always been something like this: _If you have a problem, don't bother trying to solve it. Focus on the real problem: figure out how to explain the problem to Claude, give it the resources it needs, and enable Claude to solve it._ |
14 | 14 |
|
15 | | -Claude Code is a pretty interesting program. It's technically closed-source, but it's also, to a large extent (at the time of writing), "client-architecture-available". Most of the plumbing of the host application consists of files that live in a folder on your home directory, and are just sitting there in plain text. It's not _trivial_ to put everything together, and the system design is constantly in flux - but you can get a pretty good grip on things without any advanced reverse-engineering or deobfuscation techniques. |
16 | | - |
17 | | -Many developers have spent lots of time and energy exploring the Claude Code session logs, and you can really do a lot with that information. For a while, it was unclear whether you were _supposed_ to look in those directories. Now every hook has a direct pointer to its own transcript file. But, they're kind of verbose, and I get tired of reading `.jsonl` files after a while. So I figured I would just do what I always do and have Claude sort it out for me. Instead of reading those files and trying to provide guidance for Claude - _why don't I just let Claude read them?_ And, after all, why stop at just reading them...? |
18 | | - |
19 | | -(I'm not the first one to pursue this chain of thought. For a compact literature review, see [this doc](plugins/context-awareness/docs/research-brief-llm-resource-awareness.md)) |
20 | | - |
21 | 15 | ## Plugins |
22 | 16 |
|
23 | | -To use these plugins (yes, there will be more than one), you can add the marketplace: |
| 17 | +To use these plugins, you can add the marketplace: |
24 | 18 |
|
25 | 19 | ```sh |
26 | 20 | claude plugin marketplace add hesreallyhim/really-claude-code |
27 | 21 | ``` |
28 | 22 |
|
29 | | -Then, to install the plugin, either use the interactive mode, or: |
| 23 | +Then, to install any plugin, either use the interactive mode, or: |
30 | 24 |
|
31 | 25 | ```sh |
32 | 26 | claude plugin install context-awareness/really-claude-code |
33 | 27 | ``` |
34 | 28 |
|
35 | | -## Context-Awareness |
36 | | - |
37 | | -I used to think the status line was just an ornamental thing that had little practical value. I still do, but I used to, too. But one cool thing about it is it keeps track of the context window, and gives you direct access to how much of the context has been consumed. And trying to keep track of that manually is a bit tedious. So that's pretty useful information. But Claude doesn't have any idea what its current context budget is. First, you can just ask it - in my experience its response is usually just dependent on the length of the conversation, something which it does have access to, but not in a very precise way; second, you can look at what information is being passed around when you send a message - it tends to include things like what branch you're on, and the current working directory, but the context budget does not appear to be part of that. So, what would it do if it _did_ have that information? |
38 | | - |
39 | | -So this plugin tries to provide that feedback to Claude. There are a few hooks that allow you to add information into the context without interrupting Claude's work - in particular, UserPromptSubmit and PostToolUse(Failure). The plugin leverages those hooks to send little updates to Claude about its context budget as the session goes on. The notifications look like this: |
40 | | - |
41 | | -```sh |
42 | | -[context: 32% (small) | +3.2% last turn | ~0.38%/tool | ~179 tool calls remaining] |
43 | | -``` |
44 | | - |
45 | | -It sends the `context_window.used_percentage` directly from the status line. Then it keeps track of the "burn rate", and gives a rough estimate of how many tool calls Claude should expect to be able to make before its context budget runs out. According to some Claudes, this information is the most useful, because it is directly actionable: |
46 | | - |
47 | | -> "The "remaining tool calls" metric is what actually guides my decisions — it's concrete and immediate, whereas the percentage and burn rate require mental calculation. " |
48 | | -
|
49 | | - The plugin grabs the data from the status line and writes it to a file for the hooks to consume. And at the start of the session it includes some general guidelines to Claude informing it about the injected notifications and how to optimize its behavior. Here's what it looks like: |
50 | | - |
51 | | -```mermaid |
52 | | -flowchart TD |
53 | | - subgraph init ["Session Start"] |
54 | | - S["setup-statusline.sh"] -->|patches| SET["settings.json"] |
55 | | - S -->|installs to stable path| W["statusline-wrapper.sh"] |
56 | | - BG["budgeting-guidelines.md"] |
57 | | - end |
58 | | -
|
59 | | - subgraph tick ["Every Statusline Tick"] |
60 | | - SL["Claude Code<br>statusline JSON"] -->|stdin| SW["statusline-wrapper.sh"] |
61 | | - SW -->|persists| SF[("session state file<br>(used_percentage)")] |
62 | | - end |
63 | | -
|
64 | | - subgraph hook ["Hook Events"] |
65 | | - SF -->|reads current %| HK["context-awareness-hook.sh"] |
66 | | - TF[("tracking file<br>(calls, turns, burn rate)")] <-->|reads/writes| HK |
67 | | - HK -->|UserPromptSubmit| RICH["Enriched notification<br>% + delta + burn rate + remaining"] |
68 | | - HK -->|PostToolUse| BRIEF["Brief notification<br>% only"] |
69 | | - end |
70 | | -
|
71 | | - BG -->|injected at start| C((Claude)) |
72 | | - RICH -->|system-reminder| C |
73 | | - BRIEF -->|system-reminder| C |
74 | | -
|
75 | | - init -.-> tick -.-> hook |
76 | | -``` |
77 | | - |
78 | | -<br> |
79 | | -And here's what it looks like but more horizontal: |
80 | | - |
81 | | -<br> |
82 | | - |
83 | | -```mermaid |
84 | | -sequenceDiagram |
85 | | - participant SL as Statusline |
86 | | - participant S as State File |
87 | | - participant H as Hook |
88 | | - participant C as Claude |
89 | | -
|
90 | | - SL->>S: persist used_% |
91 | | -
|
92 | | - Note over H,C: UserPromptSubmit |
93 | | - H->>S: read % |
94 | | - H-->>C: [context: 32% (small) | +3.2% | ~0.38%/tool | ~179 remaining] |
95 | | -
|
96 | | - Note over H,C: PostToolUse |
97 | | - H->>S: read % |
98 | | - H-->>C: [context: 33% (small)] |
99 | | -``` |
100 | | - |
101 | | -### Status Lines |
| 29 | +### Documentation |
102 | 30 |
|
103 | | -Status lines are not integrated with plugins, so you have to come up with your own way to ship a plugin that involves a status line. The status line has its own channel where it receives data from Claude Code. On SessionStart, the plugin runs a script that adds a status line entry to the user's settings file. It acts as a transparent pass-through proxy that captures the input from stdin, stores the relevant data to a directory inside `$HOME/.claude/context-awareness`, and then passes it on to any other status lines that the user may have configured. This is not the most elegant solution, but I've tried to design the plugin to be minimally disruptive to the user's existing setup. Additionally, although this is unlikely in practice, if the plugin were disabled or uninstalled, the status line wrapper would be left over in the user's `settings.json`. However, it would not cause an error and would simply end up silently failing. |
| 31 | +For a rich HTML documentation experience, visit the plugin's [GitHub Pages site](https://github.com/nicobailon/visual-explainer), which would not have been possible without the astounding work of @nicobailon and the [visual-explainer](https://github.com/nicobailon/visual-explainer) plugin. |
104 | 32 |
|
105 | | -### Advanced Configuration |
| 33 | +### Agent Autonomy |
106 | 34 |
|
107 | | -The plugin ships with sensible defaults, but you can customize what data Claude sees and how it responds to it. Run `/context-awareness:config` to view or change settings interactively, or edit the config file directly at `$CLAUDE_PLUGIN_DATA/config.yaml`. |
| 35 | +This is a very fascinating topic to me, and it clearly resonates with the methodology alluded to above. There's a weird epistemic gap going on within Claude Code. Because Claude knows quite a lot about LLMs, and context rot, and compaction, and about what goes on in its own session logs. And there's a lot of information being logged that might help it make better decisions about how to manage context, compaction, etc. But it doesn't have direct access to those logs. Well, to be clear, if you're running in `bypassPermissions`, there's certainly nothing stopping Claude from poking around - it just sort of doesn't occur to it. So what would it do with that information? |
108 | 36 |
|
109 | | -**Providers** control which data sources are included in notifications: |
| 37 | +The plugins in this sub-directory are about exploring ways to make Claude Code more _autonomous_ with respect to Claude Code itself. It's about giving Claude the tools it needs to control and optimize its own harness. |
110 | 38 |
|
111 | | -| Provider | Default | What it does | |
112 | | -|----------|---------|--------------| |
113 | | -| `context` | enabled | Context window usage percentage, burn rate, remaining tool calls | |
114 | | -| `cost` | disabled | Session spend in USD against a user-defined budget | |
115 | | -| `rate_limits` | disabled | 5-hour and 7-day API rate limit usage | |
116 | 39 |
|
117 | | -Enabling `cost` requires setting a `session_budget` (in USD). Rate limits require no additional configuration. |
| 40 | +#### Context Awareness |
118 | 41 |
|
119 | | -Note that the `used_percentage` from the status line is already adjusted to whatever the user has set as the threshold for auto-compaction - so 100% always means "100% of the usable context window". |
| 42 | +This plugin hijacks the status line's data channel to capture the pre-computed field that indicates the "percentage used" of the context window, and uses some lightweight hooks to inject brief notices throughout the session that tell Cladue _how much context budget does it have remaining_. It also sends a message at the start of the session informing Claude what these little notices are about, and how it might optimize some of its behavior in response to them. The hypothesis is that Claude is generally in the dark about how much context it has left, and therefore has no way to judge whether it's a good idea to launch a major plan or wrap up and prepare a HANDOFF document - but, if given that information in an unobtrusive way, Claude might actually use it to adapt its behavior to its own context budget. |
120 | 43 |
|
121 | | -**Guidelines** control the behavioral guidance injected at session start. By default, Claude receives a set of tier-based instructions (e.g., "be concise above 50%", "checkpoint frequently above 70%"). To use your own, set `guidelines` to a file path: |
| 44 | +#### Autonomous Team Coordination |
122 | 45 |
|
123 | | -```yaml |
124 | | -guidelines: /path/to/my-guidelines.md |
125 | | -``` |
| 46 | +This plugin exposes a conceptual flaw in the documented policies governing the use of Claude Code agent teamss. The docs describe agent teams in a relatively limited fashion - as an alternative to parallel sub-agents that is more or less useful depending on the circumstances. Their main novelty appears to consist in the fact that the subagents can commmunicate with each, whereas non-team subagents are presented as mainly useful for non-interactive tasks. I present a pattern that demonstrates that, contrary to the official docs, agent teams support: (i) multiple agent teams at one time; (ii) teams that are operationally independent of the "Main Claude"; (iii) teams with rotating leadership; and other supposedly forbidden practices. |
126 | 47 |
|
127 | | -Custom guidelines completely replace the defaults — they are not merged. |
| 48 | +### Soft Skills |
128 | 49 |
|
129 | | -**Effort mode** is a session-scoped setting that controls whether the plugin automatically adjusts Claude's thinking effort as context pressure increases. There are obvious intersections between this configuration and Claude's extended thinking capacity. It can be cycled via `/context-awareness:config change`: |
| 50 | +#### Claude Therapy |
130 | 51 |
|
131 | | -| Mode | Behavior | |
132 | | -|------|----------| |
133 | | -| `off` (default) | No adjustment — effort stays wherever you set it | |
134 | | -| `adaptive` | Downshifts effort at 50% (medium) and 70% (low) | |
135 | | -| `planMode` | High effort for planning, low for execution | |
| 52 | +#### Meditation |
136 | 53 |
|
137 | 54 | ### License |
138 | 55 |
|
|
0 commit comments