Use Cases
Before technology selection, architecture design, or code generation, you need to first understand the tech stack currently used by the project, in order to:
- Follow the project's existing technology choices
- Generate code that conforms to project standards
- Avoid introducing incompatible technologies
Detection Methods
1. Detect configuration files
Use Read or Glob tools to detect configuration files in the project root directory:
JavaScript/TypeScript Ecosystem
| File | Description | Detection Content |
|---|---|---|
package.json |
Node.js project configuration | dependencies, devDependencies, scripts |
tsconfig.json |
TypeScript configuration | Confirm TypeScript is used |
next.config.js |
Next.js configuration | Confirm Next.js is used |
vite.config.js |
Vite configuration | Confirm Vite is used |
nuxt.config.js |
Nuxt configuration | Confirm Nuxt is used |
Detection Command:
# 检测是否存在
ls package.json tsconfig.json next.config.js vite.config.js 2>/dev/null
# 读取 package.json
Read(file_path: "package.json")
Key Dependency Identification:
react: React projectvue: Vue projectnext: Next.js project@angular/core: Angular projectexpress: Express backendfastify: Fastify backendprisma: Prisma ORMtypeorm: TypeORM
Python Ecosystem
| File | Description | Detection Content |
|---|---|---|
requirements.txt |
pip dependencies | Dependency list |
pyproject.toml |
Poetry/PDM configuration | Dependencies and project configuration |
Pipfile |
Pipenv configuration | Dependencies |
setup.py |
Package configuration | Project metadata |
Key Dependency Identification:
django: Django projectflask: Flask projectfastapi: FastAPI projectsqlalchemy: SQLAlchemy ORMpytest: Uses pytest for testing
Go Ecosystem
| File | Description | Detection Content |
|---|---|---|
go.mod |
Go module configuration | Dependencies and Go version |
go.sum |
Dependency checksums | Confirm dependencies are locked |
Key Dependency Identification:
github.com/gin-gonic/gin: Gin frameworkgithub.com/gofiber/fiber: Fiber frameworkgorm.io/gorm: GORM ORM
Rust Ecosystem
| File | Description | Detection Content |
|---|---|---|
Cargo.toml |
Cargo configuration | Dependencies and project configuration |
Cargo.lock |
Dependency locking | Confirm dependency versions |
Key Dependency Identification:
actix-web: Actix Web frameworkaxum: Axum frameworktokio: Async runtime
Java/Kotlin Ecosystem
| File | Description | Detection Content |
|---|---|---|
pom.xml |
Maven configuration | Dependencies and plugins |
build.gradle |
Gradle configuration | Dependencies and tasks |
Key Dependency Identification:
spring-boot-starter: Spring Boot projectquarkus: Quarkus projectmicronaut: Micronaut project
Ruby Ecosystem
| File | Description | Detection Content |
|---|---|---|
Gemfile |
Bundler configuration | Dependencies |
Gemfile.lock |
Dependency locking | Confirm dependency versions |
Key dependency identification:
rails: Ruby on Rails projectsinatra: Sinatra project
2. Detect database configuration
| File/Directory | Description |
|---|---|
prisma/schema.prisma |
Prisma database configuration |
drizzle.config.ts |
Drizzle ORM configuration |
ormconfig.json |
TypeORM configuration |
alembic/ |
Python Alembic migrations |
migrations/ |
Database migration directory |
Database type identification:
postgresql://: PostgreSQLmysql://: MySQLmongodb://: MongoDBsqlite:: SQLiteredis://: Redis
3. Detect deployment configuration
| File | Description |
|---|---|
Dockerfile |
Docker containerization |
docker-compose.yml |
Docker Compose multi-container |
vercel.json |
Vercel deployment |
.github/workflows/ |
GitHub Actions CI/CD |
netlify.toml |
Netlify deployment |
railway.json |
Railway deployment |
4. Detect testing framework
JavaScript/TypeScript
| File/Dependency | Framework |
|---|---|
jest.config.js |
Jest |
vitest.config.js |
Vitest |
playwright.config.js |
Playwright |
cypress.json |
Cypress |
Python
| Dependency | Framework |
|---|---|
pytest |
pytest |
unittest |
unittest (built-in) |
Go
| File | Framework |
|---|---|
*_test.go |
Go built-in testing |
Detection process
Step 1: Detect project type
# 使用 Glob 查找配置文件
Glob(pattern: "{package.json,go.mod,Cargo.toml,pom.xml,requirements.txt,Gemfile}")
Step 2: Read configuration files
# 读取主配置文件
Read(file_path: "package.json") # 或其他检测到的文件
Step 3: Analyze dependencies
Extract from configuration files:
- Language and version: e.g. Node.js 18, Python 3.11, Go 1.21
- Main framework: e.g. Next.js 14, Django 5.0, Gin
- Database: e.g. PostgreSQL, MongoDB
- ORM: e.g. Prisma, SQLAlchemy, GORM
- Testing framework: e.g. Jest, pytest
- Build tool: e.g. Vite, Webpack, esbuild
Step 4: Output detection results
Output in a structured format:
## 技术栈检测结果
### 语言和运行时
- **语言**:TypeScript
- **运行时**:Node.js 20.x
- **包管理器**:pnpm
### 前端框架
- **框架**:Next.js 14 (App Router)
- **UI 库**:React 18
- **样式**:Tailwind CSS
- **状态管理**:Zustand
### 后端框架
- **框架**:Next.js API Routes
- **ORM**:Prisma
- **数据库**:PostgreSQL
### 测试
- **单元测试**:Vitest
- **E2E 测试**:Playwright
### 部署
- **容器化**:Docker
- **CI/CD**:GitHub Actions
- **托管**:Vercel
Usage examples
Example 1: Detect a Next.js project
# 1. 检测配置文件
Glob(pattern: "package.json")
# 2. 读取 package.json
Read(file_path: "package.json")
# 3. 分析依赖
# 发现: "next": "14.0.0", "react": "18.2.0", "prisma": "5.0.0"
# 4. 输出结果
技术栈:Next.js 14 + React 18 + Prisma + PostgreSQL
Example 2: Detect a Python project
# 1. 检测配置文件
Glob(pattern: "{requirements.txt,pyproject.toml}")
# 2. 读取配置
Read(file_path: "pyproject.toml")
# 3. 分析依赖
# 发现: fastapi, sqlalchemy, pytest
# 4. 输出结果
技术栈:FastAPI + SQLAlchemy + PostgreSQL + pytest
Notes
- Prioritize detecting existing projects: If the project already has configuration files, the existing tech stack must be followed
- Only choose a stack for new projects: Only perform technology selection when there are no configuration files
- Version compatibility: Pay attention to version compatibility between dependencies
- Ecosystem consistency: Do not mix tools from different ecosystems (such as npm + poetry)
Common mistakes
❌ Assuming without detecting: Directly assuming a project uses a certain technology without detecting configuration files ❌ Ignoring versions: Only detecting framework names, not version numbers ❌ Mixing ecosystems: Recommending Python tools in a Node.js project ❌ Duplicate detection: Detecting the same configuration files multiple times in the same task