agentleFS
cenconq25cenconq25/claude-code-app-studio/.claude/skills/extract/SKILL.md

extract

Skill40 starsChanged 7 months agoMITView on GitHub

Extracts patterns from existing source code into a structured system.md file — naming, state shape, navigation pattern, error handling, and component composition. Used as the first step inside /reverse-document and on its own when the team wants to capture undocumented conventions in a brownfield project.

37 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ai-act-readiness, c-level-agents and 10 more.

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.

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 35 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If no path was passed, ask:

    line 40
  2. Distinctive:

    Use Glob to confirm the target exists and resolve to a list of files.

    line 49
  3. Distinctive:

    Read each file. For each, classify by role: screen, component, hook/composable, store, service, util, type definition, test.

    line 57
  4. Distinctive:

    Do not summarize each file in the output — the goal is the cross-file pattern.

    line 66
  5. Distinctive:

    Test framework actually used

    line 117
  6. Very specific:

    Ask: "May I write this to design/extracted/<system>.md?"

    line 197
  7. Distinctive:

    After writing, suggest one of:

    line 203

“Common” is measured: kept by at least 6 in 10 of the 35 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

Extract — Code Pattern Capture

Reads existing implementation and produces a system.md describing how the code is actually built — not how it should be. This is descriptive, not prescriptive.

Output: design/extracted/<system-or-area>.md


Purpose / When to Run

Run when:

  • A brownfield project has working code but no design docs
  • /reverse-document is running and needs the extracted patterns as input
  • The team wants a "this is how we currently do it" snapshot before making a change

Distinct from /design-system (which authors a forward-looking PRD) and /architecture-decision (which records a deliberate decision). This skill captures observed reality so a future PRD or ADR can be written against an honest baseline.

Inputs

  • Required: a path or glob pointing to the source files to analyze (e.g., src/screens/auth/, lib/features/onboarding/**/*.dart)
  • The framework (read from .claude/docs/technical-preferences.md)

Outputs

  • design/extracted/<system-name>.md

Phase 1: Resolve Scope

If no path was passed, ask:

  • Prompt: "Which area of code should I extract patterns from?"
  • Options:
    • Screens / pages — src/screens/**, lib/features/**, app/Sources/**/Views/
    • State management — wherever the app's stores / view models live
    • Networking / API client — fetchers, interceptors
    • Navigation — routing config, deep links
    • Specific subdirectory — free text path

Use Glob to confirm the target exists and resolve to a list of files. Cap at ~50 files for one extraction; if more, sample and ask whether to chunk.

Determine the system name from the path (e.g., src/screens/auth/ → auth).


Phase 2: Read & Skim

Read each file. For each, classify by role: screen, component, hook/composable, store, service, util, type definition, test.

While reading, build a fact table per file:

  • Imports (which dependencies and from where)
  • Exported names
  • State shape (if a store)
  • Side effects (network calls, persistence reads/writes, navigation)
  • Error handling pattern

Do not summarize each file in the output — the goal is the cross-file pattern.


Phase 3: Identify Patterns

Group findings into pattern categories:

3a: Naming

  • File naming: kebab-case.tsx, PascalCase.swift, etc.
  • Component naming: <ScreenName>Screen.tsx, <Feature>Page.dart
  • State naming: useAuthStore, AuthViewModel, AuthBloc
  • Hooks/composables: useX, with<X>

3b: State management

What library or pattern shows up:

  • React Native: Redux, Zustand, Jotai, MobX, Context+useReducer
  • Flutter: Provider, Riverpod, BLoC, GetX
  • iOS native: ObservableObject, TCA, Combine, Redux-style
  • Android native: ViewModel + StateFlow, MVI, Compose state

Capture how state is shaped (entity vs. ui state, normalized vs. nested), and where mutations happen.

3c: Navigation

  • Library: React Navigation, Expo Router, GoRouter, NavigationStack, Compose Navigation, etc.
  • Pattern: stack / tab / drawer / mixed
  • Deep-link handling: present? where?
  • Auth-gated routes: pattern used

3d: Networking

  • Client library: fetch, Axios, Dio, URLSession, Ktor, Retrofit
  • Auth: token in headers, biometric refresh, etc.
  • Error handling: thrown / Result type / sealed class

3e: Error & loading states

  • How does code handle network failures, timeouts, validation errors
  • Where do loading indicators live (per-screen, global, hooked into store)

3f: Persistence

  • Local storage: AsyncStorage, MMKV, SharedPreferences, UserDefaults, Hive, Drift, SwiftData
  • Secure storage: Keychain, EncryptedSharedPreferences, react-native-keychain
  • Cache invalidation: pattern observed

3g: Testing

  • Test framework actually used
  • Files-with-tests vs. files-without — count

3h: Dependencies

  • Top 10 third-party deps from package.json / pubspec.yaml / Podfile / build.gradle

Phase 4: Spot Inconsistencies

The point of extraction is to surface drift. For each pattern category, note where the codebase disagrees with itself:

  • "12 screens use useAuthStore, 3 use useContext(AuthContext) directly."
  • "8 services throw on error; 2 return Result<T, E>."
  • "Most screens have a Loading state; 4 do not."

Inconsistencies are not bugs — they are evidence the team has not made a decision. List each one for the eventual ADR.


Phase 5: Draft system.md

Write design/extracted/<system-name>.md:

# Extracted Patterns: <System Name>

> **Status**: Descriptive (not prescriptive)
> **Source path**: <glob>
> **Files analyzed**: <count>
> **Extracted on**: <date>
> **Framework**: <name + version from technical-preferences.md>

## 1. Summary
[3-4 sentences describing what this code does, in plain terms.]

## 2. Naming Patterns
- Files: <observed convention>
- Components: <observed convention>
- State: <observed convention>
- Tests: <observed convention>
[Note any inconsistencies.]

## 3. State Management
- Library: <name>
- Shape: <entity-first / ui-first / mixed>
- Mutation pattern: <where mutations occur>
- Example: <one short snippet showing the dominant pattern, paraphrased>

## 4. Navigation
- Library: <name>
- Top-level structure: <stack / tabs / drawer / mixed>
- Deep links: <present | not present>
- Auth gating: <pattern>

## 5. Networking
- Client: <library>
- Auth handling: <pattern>
- Error handling: <pattern>

## 6. Loading & Error States
- Loading: <pattern + where it lives>
- Error: <pattern + where it lives>
- Empty: <pattern, if observable>

## 7. Persistence
- Local: <library>
- Secure: <library or "none">

## 8. Testing
- Framework: <name>
- Coverage observation: <X of Y files have tests>

## 9. Inconsistencies Worth Resolving
- [list — each becomes a candidate ADR or PRD note]

## 10. Open Questions
- [things the code does not make obvious — invitation for the team to clarify]

Ask: "May I write this to design/extracted/<system>.md?"


Phase 6: Hand-off Suggestion

After writing, suggest one of:

  • /reverse-document <system> — generate a forward-looking PRD or architecture doc on top of this extraction
  • /architecture-decision <inconsistency> — record a decision for one of the surfaced drifts
  • /design-system retrofit design/prd/<system>.md — if a partial PRD exists, fill it from the extraction

Examples

/extract src/screens/onboarding/

  • 18 files: 6 screens, 4 hooks, 2 stores, 3 services, 3 types
  • State: Zustand
  • Navigation: React Navigation v6, stack inside a tab
  • Inconsistency: 5 screens use useAuthStore, 1 still uses Context API directly
  • Output: design/extracted/onboarding.md

/extract lib/features/auth/

  • Flutter project, Riverpod state, GoRouter navigation
  • Inconsistency: 2 services use Result<T, AppError>, 1 still throws
  • Output: design/extracted/auth.md

Quality Gates

  • Output must be descriptive, not prescriptive — no "should" language.
  • Inconsistencies section must list at least one item or explicitly state "no observed inconsistencies."
  • File counts in the doc must match the glob result — no inflated numbers.
  • The doc must not invent abstractions the code does not have. If code is messy, the doc says so.

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.