You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplify AGENTS.md coding rules into prioritized tiers
Consolidate 17 flat rules into 13 tiered rules (MUST/SHOULD/CONSIDER)
to improve agent compliance. Merge redundant reuse-code rules, drop
unenforceable aspirational guidance, and make every rule mechanically
verifiable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+25-23Lines changed: 25 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,26 +101,28 @@ This document captures the current architecture, coding conventions, and design
101
101
-`crates/notedeck_dave/docs/*.md` for agent-style tooling and streaming patterns.
102
102
-`crates/notedeck_ui/docs/components.md` for reusable widgets.
103
103
104
-
## Notedeck Coding Patterns
105
-
106
-
1. Please make all **commits logically distinct**.
107
-
2. Please make all **commits standalone** (i.e. so that they can be readily removed tens of commits later without impact the rest of the code).
108
-
3. Related to logically distinct code, and standalone commits care must be taken for all **code to be human readable, and reviewable by human developers**.
109
-
4. Please set up code for **performance profiling utilizing puffin** (e.g. `cargo run --release --features puffin`).
110
-
5. Related to **Puffin & performance profiling**, for code suspected of impacting performance, carefully consider adding performance profiling attributes such as e.g. profiling::function in order to see functions performance in the profiler.
111
-
6.**Global variables are not allowed** in this codebase, even if they are thread local. State should be managed in an struct that is passed in as reference.
112
-
7.**Inspect notedeck code for reusable components, elements, patterns** etc. before creating new code for both A) notedeck updates, and B) apps built on notedeck.
113
-
8.**Nevernesting** — favor early returns and guard clauses over deeply nested conditionals; simplify control flow by exiting early instead of wrapping logic in multiple layers of `if` statements.
114
-
9.**Do not fudge CI tests**, in order to get a commit or PR to pass. Instead identify the underlying root cause of CI failure, and address that.
115
-
10. Before proposing changes, please **review and analyze if a change or upgrade to nostrdb** is beneficial to the change at hand.
116
-
11.**Ensure docstring coverage** for any code added, or modified.
117
-
12. Run **cargo fmt, cargo clippy, cargo test**.
118
-
13.**Do not vendor code**. In cargo.toml replace the existing url with the fork that includes the new code. If vendoring is absolutely necessary you must present the case why no other options are feasible.
119
-
14.**Avoid Mutexes** — prefer `poll_promise::Promise` for async results, `Rc<RefCell<>>` for single-threaded interior mutability, or `tokio::sync::RwLock` when cross-thread sharing is truly necessary. Mutexes can cause UI stalls if held across frames.
120
-
15.**Per-frame UI constraints** — the UI runs every frame; never block the render loop. Use `Promise::ready()` for non-blocking result checks. Offload CPU-heavy work to `JobPool` or `tokio::spawn()`, returning results via channels or Promises.
121
-
16.**Cherry-pick commits** — when incorporating work from other branches or contributors, use `git cherry-pick` to preserve original authorship rather than copying code manually.
122
-
17.**Frame-aware animations** — for animations (GIFs, video), track `repaint_at` timestamps and only request repaints when necessary; avoid spinning every frame.
123
-
124
-
125
-
126
-
Use this guide as a launchpad when extending Notedeck with new agents or protocol features. It highlights where to attach new functionality without duplicating existing infrastructure.
104
+
## Notedeck Coding Rules
105
+
106
+
### MUST — violations block merge
107
+
108
+
1.**No global state.** State lives in structs passed by reference. No global variables, not even thread-local.
109
+
2.**Never block the render loop.** Use `Promise::ready()` for async results, `JobPool` or `tokio::spawn()` for heavy work. Avoid Mutexes; prefer `Rc<RefCell<>>` or `tokio::sync::RwLock`.
110
+
3.**No vendored code.** Fork the dependency and reference the fork in `Cargo.toml`.
111
+
4.**No fudging CI.** Fix root causes; never disable or weaken tests to pass CI.
112
+
5.**Run `cargo fmt`, `cargo clippy`, `cargo test` before every commit.**
113
+
114
+
### SHOULD — reviewers will push back
115
+
116
+
6.**Reuse before creating.** Search the codebase for existing components, patterns, and utilities before writing new code. Never duplicate functionality that already exists.
117
+
7.**Flat control flow.** Early returns and guard clauses, not nested `if` blocks ("nevernesting").
118
+
8.**Standalone commits.** Each commit compiles independently and can be reverted without breaking later commits. Squash fix-up commits into the original via rebase.
119
+
9.**Docstrings on all new or modified public items.**
120
+
10.**Check if a nostrdb change would simplify the approach** before proposing application-level workarounds.
121
+
122
+
### CONSIDER — quality signals for review
123
+
124
+
11. Add `#[profiling::function]` on suspected hot paths (test with `cargo run --release --features puffin`).
125
+
12. For animations, use `repaint_at` timestamps instead of requesting repaints every frame.
126
+
13. Use `git cherry-pick` to preserve original authorship when pulling in external work.
127
+
128
+
Use this guide as a launchpad when extending Notedeck with new agents or protocol features.
0 commit comments