Skip to main content

When two packages need the same state, do not make one package read another package’s private object. Put the shared product fact in Bitfield and let each package read the view it needs.

A file tree chooses a file, then the editor, breadcrumbs, command palette, and AI context panel all need the active file. That state is no longer a private file-tree detail. It is product coordination state.Every package should see the same selected file without importing the file tree, sharing memory with it, or duplicating its private store.

Traditional app shape

This works until it does not. The editor now imports the file tree store. If the file tree changes its store shape, moves packages, or becomes a different UI, the editor breaks.

Bitfield shape

No package reads the file tree’s private object. They all read the shared Bitfield fact.

Code translation

Traditional path

Bitfield path

React adapter example

React is only the adapter shown here. The same rule applies to any shell: read the named Bitfield input instead of importing the file tree.

Review checklist

More examples

One product fact, many readers

The mental model is simple: a product fact is not owned by the first UI that touched it. The file tree might be the place where a user selected a file, but “the selected file” is not the file tree’s private object once the editor, AI panel, breadcrumbs, and command palette all need it.Traditional code turns the first UI into the source every other package imports:
Bitfield code turns the fact into a named product value:

React adapter example

The AI panel does not import the tree, command palette, recent-files list, command-line launch, or another device path. It reads the product fact it needs.

Four shared-state situations

Selected file

Private file-tree read

Read the public selected file

Use this when multiple packages react to the same selected file.

Current project

Private workspace read

Read the public project

Use this when panels, package filters, build actions, and account surfaces all need the same project context.

Selected agent

Private agent setter

Request the selected-agent change

Then readers use the selected-agent product fact instead of importing the setter package.

Notification mode

Private notification object

Request the mode change

Readers should observe the public mode value. Callers should not mutate notification package objects.

What not to store as shared state

What this prevents

Common mistake

Do not put every piece of state in Bitfield.

Review check

When code imports another package’s store, stop. Ask whether the value is a shared product fact. If yes, read a Bitfield input. If no, keep it private to the package that uses it.

Next

Last modified on May 10, 2026