synchronization-implementation

Instructions for writing synchronizations in TypeScript. A synchronization is a rule that reacts to an action in one concept and can trigger actions in other concepts.

In plain words
What is it for?
Use them to connect concept actions, make concepts reactive, and implement behavior that runs when matching actions occur.
Why use it?
They replace a separate synchronization language with regular TypeScript and explain how concepts must be registered so changes can trigger these rules.

Cursor rule for Cursor

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 rules/eagonmeng/sync-blank/synchronization-implementation
Clone the repo
git clone --depth 1 https://github.com/eagonmeng/sync-blank

Made for: Cursor.

Per session 1,216 This file is loaded in full into every session.
When invoked 1,216 The same file — it is already loaded in full.
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.01216 $0.01216
Opus 5 $0.00608 $0.00608
Sonnet 5 $0.00243 $0.00243
Haiku 4.5 $0.00122 $0.00122

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

Security

Grade A, and why

synchronization-implementation 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.

.cursor/rules/synchronization-implementation.mdc · 141 lines

How it starts

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

Implementing Synchronizations

Instead of relying on a custom synchronization language and parser, the current engine provides a TypeScript-native approach to specifying synchronizations. A complete and functional example of this can be found in:

@example.ts

After creating concept classes, you can initialize the Sync engine and instrument concepts as follows:

// Create new Sync engine
const Sync = new SyncConcept();

// Register concepts
const concepts = {
    Button: new ButtonConcept(),
    Counter: new CounterConcept(),
    Notification: new NotificationConcept(),
};

// All concepts must be instrumented to be reactive and used in a sync
const { Button, Counter, Notification } = Sync.instrument(concepts);

The original, unmodified concepts are available as (e.g.) concepts.Button, while the destructuring allows for the instrumented version Button to both participate in syncs, as well as feature as a fully reactive concept. Calling Button.clicked({ kind: "increment_counter" }), for example, will trigger all registered synchronizations.

The synchronizations shown previously in the specification language can be written in TypeScript as follows:

// Each sync is a function that returns a declarative synchronization
const ButtonIncrement = ({}: Vars) => ({
    when: actions(
        [Button.clicked, { kind: "increment_counter" }, {}],
    ),
    then: actions(
        [Counter.increment, {}],
    ),
});

Each synchronization is a simple function that returns an object with the appropriate keys, minimally containing when and then. The actions helper function enables a shorthand specification of action patterns as an array, where the first argument is the instrumented action, the second the input pattern, and in the case of the when clause, the third is the output pattern. Synchronizations may additionally have a where clause and specify variables:

// Each sync can declare the used variables by destructuring the input vars object
const NotifyWhenReachTen = ({ count }: Vars) => ({
    when: actions(
        [Button.clicked, { kind: "increment_counter" }, {}],
        [Counter.increment, {}, {}],
    ),
    where: (frames: Frames): Frames => {
        return frames
            .query(Counter._getCount, {}, { count })
            .filter(($) => {
                return $[count] > 10;
            });
    },
    then: actions(
        [Notification.notify, { message: "Reached 10" }],
    ),
});

Each synchronization function actually receives a special object that you can destructure arbitrarily to receive variables to use in your patterns. In this case, we destructure count to use it as a variable, which can be employed on the right-hand side of input/output patterns to indicate an open binding. The where clause, unlike the other two, is itself also a function that simply takes in a set of Frames and returns a set of Frames. This refers to the idea that each Frame is a Record<symbol, unknown> describing the current bindings of the current frame, where each Frame that makes it through to the then clause corresponds 1-to-1 with calling all actions in the then with those bindings.

Frames is simply a small extension of the Array class, and all of the standard methods and iterator functions can be applied to it. It additionally carries the .query method which enables query functions on concepts to receive certain inputs and produce outputs that enrich the frame. In this basic where clause it enhances every frame with a count binding. In a slightly more advanced example, something like:

.query(Comment._getByTarget, {target: post}, {comment})

says to lookup the post binding for the frame, and query the Comment concept for all comments associated with a target of that post. Note that post as a variable refers to that unique symbol for binding, and that the role of the input pattern is simply to match our current binding name to the generic accepted parameter name of Comment._getByTarget: since concepts are highly modular, we encourage general names like target to enable commenting on many kinds of things, and this pattern provides the way to map the two names. In this case we are okay with binding the comment output with a symbol of the same name, and use JavaScript's destructuring shorthand to indicate this. For such a pattern, we would expect there to be at least ({post, comment, ...}: Vars) as the input signature for the containing synchronization function.

Read the full file on GitHub · 141 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 · 141 lines · 1,216 tokens per session scan A c907c683bab9

Subscribe to this mod's changes

synchronization-implementation is a cursor rule published in the GitHub repository eagonmeng/sync-blank (4 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 1,216 tokens to every session, about $0.0061 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-31.