CLI tool that scans your codebase and generates compact, structured markdown index files for AI assistants. Instead of letting your AI tool re-read thousands of files every conversation, point it at .stack-shared-ai/ and save 50K+ tokens per session.
Currently supports Flutter, Express, NestJS, Next.js, Bun, and TypeScript libraries, with a pluggable scanner architecture for adding more frameworks.
# Run directly without installing
npx stack-shared-ai
# Or install globally
npm install -g stack-shared-ai
stack-shared-aiFrom the root of your project:
# Auto-detect framework and generate index files into .stack-shared-ai/
npx stack-shared-ai
# Preview what would be generated, without writing anything
npx stack-shared-ai --dry-run --verbose
# Scan a specific directory
npx stack-shared-ai ./path/to/projectAfter running, point your AI assistant at the .stack-shared-ai/ folder (e.g. add it to your CLAUDE.md, .cursorrules, or equivalent).
| Framework | Detection | Generated Files |
|---|---|---|
| Flutter | pubspec.yaml with flutter dependency |
deps.md, models.md, components.md, screens.md, state.md, api-client.md |
| Express | package.json with express dependency |
deps.md, routes.md, middleware.md, services.md, schema.md, config.md |
| NestJS | package.json with @nestjs/core or @nestjs/common |
deps.md, controllers.md, modules.md, providers.md, config.md |
| Next.js | package.json with next dependency |
deps.md, routes.md, layouts.md, server-actions.md, middleware.md, components.md, config.md |
| Bun | bunfig.toml, @types/bun, or scripts using bun |
deps.md, routes.md, config.md |
| TypeScript library | package.json with typescript and no app framework |
deps.md, exports.md, types.md, api.md |
Monorepos are supported β if no framework is found at the root, subdirectories are scanned.
For Flutter projects, if the Dart SDK is on PATH, the scanner uses the official analyzer package (via a small helper in dart_helper/) to extract classes, fields, and methods from .dart files. This produces more accurate results than the regex parser for edge cases (nested generics, complex constructor params, annotations). If Dart isn't installed, the scanner silently falls back to the regex parser β no configuration needed. The helper runs dart pub get once on first use.
Flutter:
deps.mdβ packages frompubspec.yamlmodels.mdβ data classes, fields, Freezed/json_serializable modelscomponents.mdβ reusable widgetsscreens.mdβ screens and GoRouter routesstate.mdβ Riverpod / Provider / Bloc stateapi-client.mdβ Dio / http API calls
Express:
deps.mdβ packages frompackage.jsonroutes.mdβ Express routes and handlersmiddleware.mdβ middleware stackservices.mdβ business logic modulesschema.mdβ database schema (e.g. Prisma)config.mdβ env vars and config
Both TypeScript and plain JavaScript Express projects are supported.
NestJS:
deps.mdβ NestJS-tailored categories (Core, NestJS Modules, Database/ORM, Auth, GraphQL, etc.)controllers.mdβ@Controller('prefix')classes with@Get/@Post/@Put/@Patch/@Deleteroutes, resolved full paths,@UseGuardsannotations, handler namesmodules.mdβ@Module({ imports, controllers, providers, exports })per moduleproviders.mdβ@Injectable()classes with public method signatures, grouped by directoryconfig.mdβ.env.examplevars,ConfigModule.forRootflags,configService.get('KEY')andprocess.env.Xreferences
NestJS detection suppresses the Express scanner to avoid double-scanning, since NestJS runs on top of Express by default.
Next.js:
deps.mdβ packages, grouped (Auth, Database, State, Forms, UI, etc.)routes.mdβ App Router pages + route handlers and Pages Router routes; route groups(marketing)stripped,[slug]β:slug, catch-all[...slug]β:slug*layouts.mdβlayout,loading,error,not-found,template,global-errorper directoryserver-actions.mdβ"use server"exported functions (file-level or per-function)middleware.mdβ rootmiddleware.tsentry + matcherscomponents.mdβ exported components tagged(client)or(server)based on"use client"directiveconfig.mdβnext.config.{ts,js,mjs}highlights, image domains, experimental flags,.env.example
Bun:
deps.mdβ Bun-friendly category map (Hono, Elysia, Drizzle, Lucia, etc.)routes.mdβBun.serve({ routes })native routing (Bun 1.2+) with method-specific handlers, plus Hono and Elysia chained routesconfig.mdβbunfig.tomlsections +package.jsonscripts that usebun
TypeScript library:
deps.mdβ runtime, peer, and dev dependencies (peer deps matter for libraries)exports.mdβpackage.jsonexports(conditional + subpath),main/module/types,bintypes.mdβ exportedinterface,type, andenumdeclarationsapi.mdβ exported functions and classes with signatures (viats-morph)
| Flag | Description |
|---|---|
-o, --output <dir> |
Output directory (default: .stack-shared-ai) |
-i, --include <dirs...> |
Only scan these directories |
-e, --exclude <dirs...> |
Exclude these directories |
-f, --framework <frameworks...> |
Force a specific framework (flutter, express, nestjs, nextjs, bun, typescript) |
-s, --schema <path> |
Path to database schema file (e.g. prisma/schema.prisma) |
--format <format> |
Output format: markdown (default) or json |
--dry-run |
Print what would be generated without writing files |
--verbose |
Show detailed scanner output |
CLI flags always override values from the config file.
Create a stack-shared-ai.config.json in your project root to set defaults:
{
"output": ".stack-shared-ai",
"include": ["src", "lib", "app"],
"exclude": ["tests", "__mocks__", "build", ".dart_tool"],
"schema": "prisma/schema.prisma",
"frameworks": ["flutter", "express"]
}After generating the index, reference .stack-shared-ai/ from your assistant's instructions file. Example for Claude Code (CLAUDE.md):
For an overview of this codebase, read the files in `.stack-shared-ai/`
before exploring source files directly.Re-run npx stack-shared-ai after major refactors to keep the index fresh.
MIT