agentleFS
elbionredenicaelbionredenica/consumer-app-starter/.agents/skills/no-use-effect/SKILL.md

no-use-effect

Skill0 starsChanged 2 months agoMITView on GitHub

Enforce the no-direct-useEffect rule in this starter. Use when writing or reviewing React code, especially screens, hooks, auth flows, and navigation wiring.

14 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use improve-codebase-architecture.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • GoogleSkill

    improve-codebase-architecture

    Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 3 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never import or call useEffect directly in this repo's app code.

    line 13
  2. Distinctive:

    Use one of these patterns instead:

    line 15
  3. Distinctive:

    use React Query for async loading and cache invalidation

    line 19
  4. Very specific:

    use a parent key to force reset/remount behavior

    line 20
  5. Very specific:

    use useMountEffect from @/hooks/use-mount-effect for true mount-only external sync

    line 21
  6. Very specific:

    If the work can be expressed with <Stack.Screen options={...} />, do that instead of mutating navigation options in an effect.

    line 35
  7. Distinctive:

    Do not fetch Supabase data inside mount effects.

    line 39
  8. Very specific:

    Use useMountEffect only for:

    line 43

“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Starter integration: root AGENTS.md and docs define the chosen stack and commands. Use Next.js for backend routes and EAS for native builds. Apply platform principles to React Native; do not create an Xcode project or product specification from these examples. Supporting references describe options, not installed capabilities.

No Direct useEffect

Never import or call useEffect directly in this repo's app code.

Use one of these patterns instead:

  • derive values during render
  • handle work in event callbacks
  • use React Query for async loading and cache invalidation
  • use a parent key to force reset/remount behavior
  • use useMountEffect from @/hooks/use-mount-effect for true mount-only external sync

Use This Skill When

  • writing a new React component or hook
  • reviewing a PR that introduces useEffect
  • refactoring existing side effects
  • touching auth/session bootstrap
  • wiring Expo Router headers or navigation options

Repo-Specific Guidance

Prefer declarative navigation

If the work can be expressed with <Stack.Screen options={...} />, do that instead of mutating navigation options in an effect.

Prefer React Query for data

Do not fetch Supabase data inside mount effects. Database-backed screen data belongs in React Query.

Allowed escape hatch

Use useMountEffect only for:

  • subscriptions
  • mount/unmount lifecycle integration
  • hydration flags
  • one-time sync with external systems

Bad reasons:

  • mirroring one piece of state into another
  • fetching data and calling setState
  • using state as a trigger so an effect performs the real action

Replacement Patterns

1. Derive state, do not sync it

// Bad
const [filtered, setFiltered] = useState(items);

useEffect(() => {
  setFiltered(items.filter((item) => item.visible));
}, [items]);

// Good
const filtered = items.filter((item) => item.visible);

2. Use React Query for async data

const { data } = useQuery({
  queryKey: ['records', recordId],
  queryFn: () => fetchRecord(recordId),
});

3. Use event handlers for user actions

// Bad
const [shouldSave, setShouldSave] = useState(false);

useEffect(() => {
  if (shouldSave) saveRecord();
}, [shouldSave]);

// Good
const handleSave = () => {
  saveRecord();
};

4. Use useMountEffect for real mount-only sync

import { useMountEffect } from '@/hooks/use-mount-effect';

useMountEffect(() => {
  const sub = api.subscribe();
  return () => sub.unsubscribe();
});

5. Reset with key, not effect choreography

<RecordEditor key={recordId} recordId={recordId} />

Verify

pnpm lint
pnpm typecheck

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.