资讯动态

agents-generator - decision-matrix

发布时间:2026/10/23 6:21:44 来源:尧图企业网站定制
决策矩阵——项目检测与规则选择检测顺序按此顺序运行检测。每个步骤读取文件并设置后续步骤使用的标志。1. 包管理器检查锁文件bun.lock→ bunpnpm-lock.yaml→ pnpmpackage-lock.json→ npmyarn.lock→ yarn。2. 项目类型根package.json中的workspaces→ 单一代码库。否则 → 单一应用。3. 框架Dep foundFrameworkRouter detectionnextNext.jsapp/haspage.tsxorlayout.tsx→ App Router;pages/has.tsx→ Pages Router; both → hybrid (treat as App Router primary)nestjs/coreNestJSN/AviteViteCheckreactfor React,vuefor Vue,sveltefor Svelteangular/coreAngularN/AexpressExpressN/AfastifyFastifyN/Aremix/remix-run/*RemixN/AastroAstroN/A4. 单仓库工具如果是单仓库File foundToolturbo.jsonTurboreponx.jsonNxlerna.jsonLernapnpm-workspace.yamlonlypnpm workspaces (no orchestrator)5. 语言tsconfig.json存在 → TypeScript。检查compilerOptions.strict: true→ 严格模式。6. CSS 方法SignalApproachtailwindcssin depsTailwind CSScomponents.jsonexistsshadcn/ui (implies Tailwind)styled-componentsin depsstyled-componentsemotion/*in depsEmotion.module.cssor.module.scssfiles foundCSS Modulessassornode-sassin depsSass/SCSSNone of the abovePlain CSS / CSS imports7. 测试Dep foundRunnerExtravitestVitestCheckvitest.config.*for env (node/jsdom/happy-dom)jestJestCheckjest.config.*for envplaywrightorplaywright/testPlaywrightE2E tests presentcypressCypressE2E tests presentNone—Skip testing rules8. 验证Dep foundLibraryzodZodyupYupclass-validatorclass-validatorvalibotValibotNonePlain TypeScript (type guards, manual validation)9. ORM / 数据库Dep foundORMDetect providerprismaPrismaReadprisma/schema.prisma→datasource db { provider ... }drizzle-ormDrizzleCheckdrizzle.config.*fordialectknexKnexCheckknexfile.*for clienttypeormTypeORMCheck config fortypemongooseMongoDB/MongooseN/A提供程序影响ID类型约定PostgreSQL使用UUIDSQLite/MySQL使用自增MongoDB使用ObjectId。10. 状态管理Dep foundLibraryzustandZustandreduxjs/toolkitRedux ToolkitjotaiJotaivaltioValtiorecoilRecoilmobxMobXxstateXStatetanstack/react-queryReact Query (server state)swrSWR (server state)NoneuseState / useReducer only服务器状态库React Query、SWR需要与客户端状态Zustand、Redux不同的规则。11. API 客户端模式SignalPatterntrpc/*in depstRPCgraphqlapollo/clientGraphQL (Apollo)graphqlrelay-runtimeGraphQL (Relay)tanstack/react-queryfetchREST with React QueryswrfetchREST with SWRaxiosin depsREST with AxiosServer action files (use server) foundServer Actionsapp/api/withroute.tsfilesNext.js API Routessrc/with NestJS controllersNestJS RESTNone of the abovefetch() directly12. 表单库Dep foundLibraryreact-hook-formreact-hook-formformikFormiktanstack/react-formTanStack Formhookform/resolversreact-hook-form Zod/Yup resolverNoneControlled/uncontrolled inputs manually13. 认证库Dep foundLibraryExtra detectionnext-authNextAuth v5 (Auth.js)Check forauth.ts,middleware.tsroute protectionnext-authv4NextAuth v4Check for[...nextauth].tsclerk/nextjsClerkCheck formiddleware.tslucia/lucia-authLuciaCheck forauth.tssupabase/supabase-jssupabase/ssrSupabase AuthCheck for middlewarefirebasefirebase/authFirebase AuthCheck forfirebase.tsconfigauth0/*Auth0Check forauth0.tsNoneNo auth or custom—14. 国际化库Dep foundLibraryExtra detectionnext-intlnext-intlChecki18n.ts,messages/, middleware configreact-i18nexti18nextreact-i18nextChecki18n.ts, locale JSON filesnext-i18nextnext-i18nextChecknext-i18next.config.jslingui/*LinguiChecklingui.config.*NoneNo i18nChecklanginhtmlfor language hint15. 后端模式SignalPatternFiles containinguse serverServer Actionsapp/api/withroute.tsNext.js API RoutesNestJS controllersNestJS RESTExpress/Fastify route filesREST APItRPC routerstRPC APIGraphQL resolversGraphQL API16. 代码检查与质量File/Dep foundTooleslintin depsESLinteslint.config.*ESLint flat config.eslintrc.*ESLint legacy configprettierin depsPrettier.prettierrc*Prettier configuredreact-doctorin depsreact-doctordoctor.config.*react-doctor configuredbiome.jsonBiome.oxlintrc.*oxlint规则文件选择将检测到的标志映射到规则文件以生成Rule FileRequired Whenarchitecture.mdAlwaysfrontend-patterns.mdHas React/Next.js/Vite/Angular/Vue/Svelte frontendbackend-patterns.mdHas NestJS backendserver-actions.mdUses server actions OR has API routes OR has NestJS/Express/Fastify backendstyling.mdHas Tailwind, CSS Modules, or styled-components (not plain CSS)forms.mdHas react-hook-form, formik, or TanStack Formdatabase.mdHas Prisma, Drizzle, Knex, TypeORM, or Mongoosei18n.mdHas next-intl, react-i18next, or similartesting.mdHas test runner (vitest/jest/playwright/cypress) in devDepsgit-workflow.mdAlwayssdd-workflow.mdAlwaysAGENTS.md 部分选择根据检测生成的 AGENTS.md 中包含的部分SectionInclude WhenMonorepo Structureworkspacesin package.jsonMonorepo Tool CommandsTurborepo/Nx/Lerna detectedNext.js Router ConventionNext.js detected → App Router vs Pages Router rulesZod Validation Conventionzodoryuporvalibotin depsPlain TS Validation ConventionNo validation library, but TypeScript strictPrisma Conventionprismain depsDrizzle Conventiondrizzle-ormin depsServer Actions Conventionuse serverfiles detectedtRPC ConventiontRPC detectedGraphQL ConventionGraphQL detectedTailwind Conventiontailwindcssin depsshadcn/ui Conventioncomponents.jsonexistsCSS Modules Convention.module.cssfiles foundStyled Components Conventionstyled-componentsin depsState Management SectionZustand/Redux/Jotai/MobX/XState in depsServer State SectionReact Query/SWR in depsForm Library Sectionreact-hook-form/formik/TanStack Form in depsi18n Sectioni18n library detectedAuth SectionAuth library detectedreact-doctor Conventiondoctor.config.*orreact-doctorin depsUI Language ConventionChecklangattribute or i18n config命令生成从package.json的scripts生成命令表。直接映射scripts键{scripts:{dev:...,build:...,lint:...,test:...}}变为ComandoQué hace{pm} devServidor de desarrollo{pm} run buildBuild de producción{pm} run lintLinting{pm} run testTests (watch)为以下内容添加额外行test:run单次运行、test:coverage、doctor、format、typecheck。其中{pm} 对于 bun不带run的脚本为bunpnpm 为pnpmnpm 为npm runyarn 为yarn。Monorepo 命令生成如果使用 Turborepo 的 monorepo生成turbo run {cmd}变体。如果使用 pnpm 的 monorepo生成pnpm --filter {pkg} {cmd}示例。如果使用 Nx 的单仓库生成nx {cmd} {pkg}变体。验证周期从检测到的工具组装{typecheck} → {lint} → {test} → {doctor}{typecheck}如果是 TypeScript则使用tsc --noEmit如果是 bun则使用bunx tsc --noEmit如果没有 TS 则跳过。{lint}:{pm} run lint或检测到的 lint 命令。{test}:{pm} run test:run或{pm} run test取单次运行的那个。{doctor}:{pm} doctor或{pm}x react-doctorlatest如果检测到 react-doctor。如果没有检测到则跳过。单仓库重建说明如果是带共享包的单一代码库添加关于在循环之前重建包的说明Si se modificaron packages compartidos ({shared_pkg_list}), ejecutar su rebuild primero: {rebuild_commands}特定框架的约定Next.js 应用路由器默认使用服务器组件。只有在使用钩子时才使用use client。服务器操作在lib/actions.ts或src/actions/。error.tsx、loading.tsx、not-found.tsx按段落。generateMetadata()用于 SEO。next/image用于图片next/font用于字体。路径别名/*→./*或./src/*。Next.js 页面路由器getServerSideProps、getStaticProps、getStaticPaths。pages/api/用于 API 路由。pages/_app.tsxpages/_document.tsx。没有服务器组件。所有都是客户端或 API。NestJS模块像目录src/{feature}/{feature}.module.ts。带装饰器的 DTO。使用class-validator或ZodValidationPipe进行验证。守卫用于身份验证UseGuards(AuthGuard)。PrismaService作为全局提供者。边缘情况SituationActionNo test runnerSkip testing.md, skip test from verification cycleNo lint toolSkip lint from verification cycleNo TypeScriptSkiptsc --noEmit, skip no-any rule, use JSDoc conventions insteadNo config files at allMinimal defaults, note that project needs setupMultiple frameworksPick primary based on root package.json, note secondaryBoth App Router and Pages RouterTreat as App Router primary, note Pages Router legacy routesNo package.json scriptsGenerate commands from direct tool invocations (npx next dev)Bun withoutbun runscriptsUsebunxprefix for npx equivalentsMonorepo without workspacesTreat eachapps/*orpackages/*as independentCSS: multiple approachesPick primary (Tailwind wins over CSS Modules over plain CSS)Auth: multiple librariesPick primary, note secondary (e.g., NextAuth for web, Clerk for admin)i18n with Pages RouterDifferent routing rules than App Router i18nDatabase with multiple providersDocument each, note which is primary

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价 →
↑