← Writing
November 24, 2026·13 min readEthicsEngineeringDesignProduct

Building Apps That Help Users Stop: Five Engineering Patterns for Behavioural Mobile Apps

Building Apps That Help Users Stop: Five Engineering Patterns for Behavioural Mobile Apps cover

I built Threshold because I had a social media problem of my own, and I was trying to cut down on how much time I spent making use of these apps. Every other site blocker I tried had the same escape hatch: you enter a password, disable the extension, or just open the site. Because I worked both as the builder and the person getting around the build, it was easy to break that pattern.

So I built one where I couldn't be the person who decides when to unblock. My girlfriend was the first other user, then a handful of friends, and now, six months after launch on the Chrome Web Store, Threshold has 457 installs across Chrome alone. We also have installs on Edge, Firefox, and Safari, with around 25 weekly active users. While these numbers might seem small, I've been able to get a real product with users who come back week after week, which is more than most behavioural-intervention tools achieve.

This article is five engineering patterns from shipping Threshold, one pattern I walked back, an opinion that will be controversial, and the ethical rubric that separates useful friction from coercion. Threshold is a browser extension, but the patterns port to mobile; the mobile surface is where most of the behaviours (doomscroll, late-night app binges, compulsive checking) live, and I've designed every pattern below with mobile implementation in mind.

The core principle: intervention happens at two levels

Most mainstream app design optimises for zero friction: things like one-tap buy, thumb-reach everything, zero-click login, autoplay. For most products, this is correct: the gap between intent and action should be as small as possible, because the gap is where users bounce.

For behavioural intervention products, the inverse is true. The gap between intent and action is where the whole product value lives. But the critical insight, the one that took me months of shipping to see, is that intervention has to happen at two distinct levels, with different kinds of friction at each.

The first level is the moment of impulse where the user is about to open a blocked site. This is an emotional moment, often happening late at night or during periods of idleness. The friction here should be designed to create reflection.

The second level is the moment of rule-change: the user, in a calmer moment, decides they want to remove a site from their blocklist entirely, change their accountability partner, or uninstall the app.

This is usually irrational and caused by quick urges to break the system. The friction here should be structural: long waits, external approval, impossible to rush.

Most site blockers only have the first kind of friction (a block page you click past) and skip the second entirely (a password unlock, disable with one click). Threshold inverts this by creating a gentle block page and enforcing the rule to make it immovable without the accountability partner approving.

Pattern 1: The block page is a pause and not a barrier

When a user hits a blocked domain, Threshold's block page takes over the full tab. Three things appear on screen, in this order:

  • A single declarative sentence: "You decided not to come here."
  • The user's own pledge, in their words from onboarding.
  • Their current streak + one line: "{Partner name} was just told."

At this point, we don't give the user an option to click or change their mind to unlock. The only two optional actions are: to start a 60-second breathing exercise, or note what's happening in a private journal entry.

The 60 seconds is deliberate, below 15 seconds and delays read as annoying but don't change behaviour, anything above 90 seconds usually causes users to abandon the page and uninstall.

The breathing exercise runs a 4-second inhale, 4-second hold, 6-second exhale cycle. From the real block page code:

function scheduleNextPhase() {
  const durations = { inhale: 4000, hold: 4000, exhale: 6000 };
  const next = { inhale: 'hold', hold: 'exhale', exhale: 'inhale' };
  phaseTimer = setTimeout(() => {
    breathPhase = next[breathPhase];
    // ...update the UI to the next phase
  }, durations[breathPhase]);
}

The journal is optional and private to the user while the partner is told the user hit a blocked attempt (and which domain), but not what the user wrote. This split where the partner sees behaviour but not the reflection is one of the most important design decisions in the product. (More on why in the walked-back section below.)

For a mobile port, the same pattern maps directly: a full-screen presentation on iOS (modal with no swipe-dismiss), a native Android activity that captures the back button, the same 60-second breathing and optional journal.

Pattern 2: Triple-redundant enforcement

This is the pattern I wish I had read before shipping v0. On Chrome extensions, the obvious way to block a URL is declarativeNetRequest register rules; Chrome enforces them at the network layer, and it works mostly.

In incognito mode, declarativeNetRequest fails to fire for some navigation paths. The user types a blocked URL into an incognito address bar; the extension is loaded and working, and the page loads anyway.

For a normal extension this is an annoying bug, but for a behavioural-intervention extension, it is a failure mode that kills the product's reason to exist.

So Threshold runs three different blocking layers in parallel, each one of them redundant with the others:

// Layer 1 — declarativeNetRequest (network-level redirect) — primary

// Layer 2 — webNavigation.onBeforeNavigate — backup, caught early
chrome.webNavigation.onBeforeNavigate.addListener(async (details) => {
  if (details.frameId !== 0) return;
  const blockUrl = await shouldBlock(details.url);
  if (blockUrl) await redirectTab(details.tabId, blockUrl, 'webNavigation');
});

// Layer 3 — tabs.onUpdated. Fires reliably in incognito for both fresh
// tabs and address-bar typed URLs. Checks both changeInfo.url AND tab.url
// so we catch every transition.
chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
  const candidate = changeInfo.url
    || (changeInfo.status === 'loading' ? tab.url : null);
  if (!candidate) return;
  const blockUrl = await shouldBlock(candidate);
  if (blockUrl) await redirectTab(tabId, blockUrl, 'tabs.onUpdated');
});

// Layer 3b — tabs.onCreated. Some incognito navigations land in a
// brand-new tab whose URL is set immediately, before any update event.
chrome.tabs.onCreated.addListener(async (tab) => {
  if (!tab.url || !tab.id) return;
  const blockUrl = await shouldBlock(tab.url);
  if (blockUrl) await redirectTab(tab.id, blockUrl, 'tabs.onCreated');
});

Each layer is a separate Chrome API with its own reliability profile. The URL resolution logic is in one shared function (shouldBlock), so matching stays consistent, but the registration is independent.

In production, I log which layer caught each redirect; the long tail is non-zero on every layer, which is why they all have to exist.

The engineering lesson generalises beyond extensions: for behavioural products, defence in depth matters more than clean architecture.

A single bypass path kills the product's value. If you have three enforcement paths and one fails, the product still works. If you have one and it fails on a random Tuesday, you have a user who is doomscrolling by Wednesday.

On mobile, the equivalent is layering OS-level screen time APIs + a VPN-based traffic filter for web content + in-app detection for your own usage events.

No single OS API covers every case, so we have to treat the cross-cutting enforcement surface as a hardening exercise rather than a feature.

Pattern 3: Partner approval as the only exit path

I built Threshold to have no "disable" button or "pause for today," or even a password override. The only way for a user to change their own restrictions, such as remove a site, swap the partner, uninstall the extension is to send a request to the accountability partner, who approves or denies it via email.

The database table that holds these requests covers five request types:

create table if not exists public.unlock_requests (
  id uuid primary key default gen_random_uuid(),
  install_id uuid not null references public.installs(id)
    on delete cascade,
  partner_id uuid references public.partners(id),
  request_type text not null,
    -- 'remove-domain' | 'remove-category' | 'change-partner'
    -- | 'adjust-schedule' | 'uninstall'
  target text,
  reason text,
  status text default 'pending',
    -- 'pending' | 'cooldown' | 'denied'
    -- | 'completed' | 'revoked' | 'expired'
  decision_token text not null unique,
  partner_email_sent_at timestamptz,
  decided_at timestamptz,
  cooldown_ends_at timestamptz,
  completed_at timestamptz,
  revoked_at timestamptz,
  created_at timestamptz default now()
);

The partner never needs to create an account. The row carries a random decision_token, and the token is embedded in the email the partner receives. Clicking Approve or Deny in that email calls a stateless Supabase edge function which validates the token and advances the status machine.

Commitment device theory from behavioural economics, Thomas Schelling called them "self-imposed penalties for unwanted behaviour", is the frame.

The user, in a moment of clarity at setup, binds themselves to a future state of less-clarity. The partner is the enforcement mechanism. What makes this work is that the partner is someone the user knows and trusts in real life, not a stranger from a random user base, not a paid service, not an AI.

For mobile, the same mechanism applies: push notification instead of email (or email as well). The underlying state and enforcement logic doesn't change.

Pattern 4: 72-hour cooldown on every structural change

There are two major moments we noticed, and we gave them both different rules: one is when they are trying to reach a blocked site; there is a sixty-second cooldown, with the accountability partner being informed.

Second is trying to change their blocked site list: first needs approval from their partner, then a seventy-two-hour wait period before they can access that site.

On the block page, from pages/block.js:

let breathRemaining = 60;
// ...
function scheduleNextPhase() {
  const durations = { inhale: 4000, hold: 4000, exhale: 6000 };
  const next = { inhale: 'hold', hold: 'exhale', exhale: 'inhale' };
  phaseTimer = setTimeout(() => {
    breathPhase = next[breathPhase];
    // ...
    scheduleNextPhase();
  }, durations[breathPhase]);
}

Sixty seconds is long enough for the impulse to pass. Four in, four hold, six out, the longer exhale pulls the parasympathetic nervous system up; this is well-trodden ground in breathwork research.

The copy on the page says exactly what the sixty seconds is for: "When this finishes, the tab is yours to close. There is nothing else to do here." The breathing isn't a lock; it's a moment.

On the removal side, from partner-decide.ts:

const COOLDOWN_MS = 72 * 60 * 60 * 1000;
// ...
if (decision === 'approve') {
  if (r.status === 'pending') {
    next = 'cooldown';
    ends = new Date(Date.now() + COOLDOWN_MS).toISOString();
    action = 'approve';
  }
}

Seventy-two hours between the partner's approval and the change actually taking effect. During that window, the partner can revoke.

The number isn't arbitrary; it's long enough that the decision isn't made in the same emotional state as the request, and short enough that it's not punitive. The user sees the countdown and knows the lock will lift at a specific time.

Pattern 5: Asymmetric trust + end-to-end encrypted sync

A behavioural product collects the most sensitive data a person generates; building this casually means you have built a surveillance product dressed as help.

Three things in Threshold's architecture exist because of this.

First, the journal. The block page offers an optional journal: "what was I feeling, what was I avoiding, what do I need right now" and the copy under the heading is explicit: Only you will see this. Your partner only sees that you wrote something.

The partner notification carries the fact of an entry, but it carries none of its contents. The entry is written to local extension storage, and from pages/block.js you can see there is no path from there to any outbound request.

Second, cross-device sync. A user on two browsers needs to share settings; doing that with a hosted account would mean the server sees everything: which sites they block, which categories, their pledge text, their partner's name. Instead, sync_blobs:

create table if not exists public.sync_blobs (
  lookup_id  text primary key,
  install_id uuid references public.installs(id) on delete cascade,
  ciphertext text not null,
  iv         text not null,
  salt       text not null,
  pulls      int default 0,
  created_at timestamptz default now(),
  expires_at timestamptz not null
);
Encrypted settings blobs for cross-browser linking, the server stores ONLY ciphertext (AES-GCM), keyed by lookup_id = SHA-256(pairing code). It never sees the code or the plaintext, so it cannot read the user's settings. Short-lived (TTL) and pull-capped to limit exposure of a leaked code.

The pairing code is generated client-side, shown once, and never transmitted. The server sees a hash and ciphertext. A full-database breach would hand an attacker a pile of opaque blobs and nothing to turn them into settings with.

Third, deny-all RLS: the extension never talks to Postgres directly; it goes through Supabase edge functions that use the service_role key. So the anon policy is this:

create policy "deny all anon" on public.installs        for all to anon using (false);
create policy "deny all anon" on public.partners        for all to anon using (false);
create policy "deny all anon" on public.attempts        for all to anon using (false);
create policy "deny all anon" on public.unlock_requests for all to anon using (false);
create policy "deny all anon" on public.sync_blobs      for all to anon using (false);

A leaked anon key reads nothing; there is no read path for the anon role. Every read is mediated by an edge function that knows what it's reading and why.

When a user hands you intimate data, the architecture is where the trust lives, not the marketing copy.

The pattern we walked back: the partner saw too much

The first pass of Threshold was more aggressive than what shipped. A few things got walked back, and the walking back is the part worth writing down.

The partner was going to see the journal; the thinking was that an accountability partner needs the full picture to help.

In practice, this collapsed the journal into a performance where the user writes what they want the partner to read, not what they feel.

The journal lost its point, and I instead decided to ship a partner being notified that an entry exists but never what's in it.

The cooldown was going to be a week; the theory was "the more friction, the more commitment."

The failure case was mundane: a user legitimately needs to change which sites are blocked because the schedule changed, or their partner is unreachable, or life moved. A week is long enough to turn a reasonable change into a punishment, while seventy-two hours keeps the delay short without becoming adversarial.

The block page was going to be a hard thirty-second wait before the "close tab" button appeared. While this worked, it felt like being punished by the product the user chose to install. So we replaced that with the breathing exercise; this keeps the duration similar while using a different frame. While one is working as a timeout, the other is a pause with something to do [Journal].

The pattern across all three: the first instinct in a behavioural product is to add friction. Friction is easy to add and hard to calibrate; every time the walked-back versions won, it won because the earlier version had confused "harder" with "more effective."

A position that will be controversial

Here's the part that will annoy people: engagement metrics are the wrong success metric for behavioural apps, and the industry has been lying to itself about this for a decade.

An app that helps someone stop a behaviour succeeds when the user needs it less. Daily active users should trend down as the product works, session length should drop, and the open rate should drop.

Every metric a growth team optimises for is an anti-signal in a product like this. A meditation app with climbing DAU is either serving people who are getting more anxious or people who have turned meditation into another thing to compulsively check; this is not a win.

The metric is counterfactual: how many times did the user not open the blocked site this week, compared to a baseline.

Threshold shows this as a streak counter, which is a flawed but defensible proxy: you're tracking the thing not happening, not the thing happening.

The partner-approval design reinforces this: the product is working when unlock requests are rare, not when they're frequent.

The spicy corollary: a behavioural app that is monetised by engagement cannot help you; the business model and the therapeutic model are directly opposed.

This is why most of the "wellness" category is wellness-shaped entertainment; the moment a user stops feeling bad, the churn risk starts.

Behavioural products need business models that reward absence: one-time purchases, charitable funding, subscriptions people keep paying after they've stopped using the app because they want it there if they slip. None of these are easy, but engagement is, and that's a trap.

The ethical rubric

A rubric for deciding whether a behavioural app you're building is good. Each question has a cheap answer that lets you keep shipping the product you already planned, and a harder answer that may force a redesign.

  1. If the user succeeds, does my product get used less? If the answer is no, you are selling engagement with a behavioural costume.
  2. Can the user bypass the restriction in a moment of weakness? If yes, if there's a settings toggle, a password the user set themselves, a "disable for today," then the product is not a commitment device but just a reminder.
  3. Who holds the exit path? The user, a trusted partner, a cooldown timer, or a combination. If the answer is "the user alone," see #2.
  4. Does the UI calibrate friction to the moment? A single friction value, one delay, or one lock is a sign you haven't thought about the distinct moments in the user's day.
  5. What is the most sensitive data the product collects, and where does it live? If the answer involves your server reading it in plaintext, that's a decision you made on purpose, and your users should know.
  6. What does the partner (or coach, or community) see? What don't they see? The default should be "the fact of an event, not its contents," and any departure from that should have a specific justification.
  7. What is the incentive of the business model with respect to the user's progress? If the business makes more money when the user is struggling, no engineering pattern will fix that.

Why this matters now

Three things have changed in the last eighteen months that make this category newly tractable, and newly urgent.

First, platform APIs have caught up: Chrome Manifest V3's declarativeNetRequest means a block list runs in the browser's network layer with no observer overhead; three years ago the same product shipped as a webRequest proxy and users could watch their CPU climb.

On iOS, Screen Time's FamilyControls and ManagedSettings frameworks (iOS 15+) and Android's UsageStatsManager + accessibility services give third-party apps enough surface to build commitment devices without rooting the device.

Second, the mental-health conversation has matured past "there's an app for that." A decade of research has built a reasonably solid consensus on what works for behavioural change: commitment devices, implementation intentions, social accountability, friction calibrated to the moment, and a reasonably solid consensus on what doesn't: streaks as the only mechanism, gamification of recovery, ambient surveillance framed as self-knowledge.

Third, the generation who grew up with these apps is building the next generation of them, and increasingly refuses to replicate the engagement playbook they themselves survived.

The engineering patterns in this piece are small on their own; the posture behind them- that a behavioural product's goal is its own obsolescence is the thing that has to become normal.

A note on how it was built

Threshold's stack is deliberately small; a Chrome MV3 extension holds the client. Supabase hosts a Postgres and a handful of edge functions written in Deno TypeScript.

A small Vercel-hosted Next.js page handles the partner decision UI; Resend sends the partner emails. There is no bespoke backend, no account system, no auth beyond the per-partner decision tokens embedded in email links.

The choices to call out:

  • Edge functions over a long-running service. Each unlock request is a single stateless function invocation. Cold start is ~200ms, which is fine when the user is waiting for an email to arrive anyway. There's no fleet to run, no queue to manage, no 3 am page about a Node process that leaked memory.
  • Postgres as the only data store. Attempts, partners, unlock requests, encrypted sync blobs, one database, one access path (service_role through edge functions), one backup to reason about.
  • Email as the partner's auth. The partner never creates an account; the decision_token in unlock_requests is the entire auth surface for their side of the product. No password, no session, no account recovery flow, and nothing for the partner to accidentally lock themselves out of at exactly the wrong moment.
  • Client-side crypto for sync. The pairing code is generated in the extension; the server sees a SHA-256 hash of it and the AES-GCM ciphertext. This isn't exotic; Web Crypto is a fine API now, but it's a decision you have to make early.

Total infrastructure cost for the current install base is in single-digit dollars per month. The Chrome extension itself is around 2,500 lines including CSS and the partner-UI web page. The whole thing is maintainable by one person.

Closing

None of the patterns in this piece are novel; triple-redundant blocking is defensive programming. Commitment devices are from Thomas Schelling, 1960; breath pacing is from clinical breathwork research.

Client-side crypto for sync is a textbook move if you ask me, but the novelty, if there is any, is in treating them as a coherent set, engineering decisions that line up with what the product is for.

The product I set out to build was one I needed; the Chrome Web Store numbers are small: 457 installs, 25 weekly active users.

The piece isn't a product pitch but a position: that a behavioural product is a software object with a specific moral character, and that engineering has more to do with that character than copy or color choice does.

If you are building in this category- habit, focus, recovery, screen time, anything that asks a user to do less of something- the design decisions you make in the first few weeks will decide whether your product can help.

The rubric above is the one I wish someone had handed me at the start; those seven questions are easy to answer and would cost you if you get them wrong while building.

The code for Threshold is open source at github.com/tvbixd/threshold-extension and the product lives at jointhehold.com. If you build something in this space and want a second pair of eyes on the architecture, write to me.