AgentSkillsCN

stack-detection

提供技术栈检测参考表与各栈专项分析指南。将项目文件映射至相应语言,将依赖关系归入对应框架,将目录结构与各领域一一对应。同时,引入更深入的分析标准,助力大语言模型驱动的代码库理解。此技能常被设置、资产生成与配置初始化命令调用。

SKILL.md
--- frontmatter
name: stack-detection
description: |
  Technology stack detection reference tables and per-stack analysis guidance.
  Maps project files to languages, dependencies to frameworks, and directory
  structures to domains. Includes deeper analysis criteria for LLM-driven
  codebase understanding. Used by setup, generate-assets, and init-config.
triggers:
  - detecting technology stack
  - scanning codebase for languages
  - identifying project frameworks
domains: [detection, stack, language, framework, domain]

Stack Detection Reference Tables

Declarative mappings for identifying a project's technology stack. Commands reference these tables rather than maintaining their own detection logic.

Language Detection

FileLanguagePackage Manager
pyproject.tomlPythonuv / pip
package.jsonJavaScript/TypeScriptnpm / yarn / pnpm
Cargo.tomlRustcargo
go.modGogo
GemfileRubybundler
build.gradle or pom.xmlJava/Kotlingradle / maven
mix.exsElixirmix

Framework Detection

LanguageDependencyFramework
PythonfastapiFastAPI
PythondjangoDjango
PythonflaskFlask
TypeScriptnextNext.js
TypeScriptexpressExpress
TypeScriptnestjsNestJS
RubyrailsRails
Rustactix-webActix
RustaxumAxum
Gogin-gonicGin
GoechoEcho
ElixirphoenixPhoenix

Domain Detection

Directory PatternDomain
models/, schemas/, entities/Data models
api/, routes/, controllers/, handlers/API layer
services/, use_cases/, ops/Business logic
storage/, db/, repositories/Data access
auth/, security/Authentication/security
tests/, spec/, __tests__/Testing
Dockerfile, docker-compose.*, .github/workflows/, k8s/Infrastructure
(detected via Framework Detection table above)Framework-specific

Gating Rules

  • Infrastructure requires 2 or more signals. A single .github/workflows/ directory alone is not sufficient — most projects have CI config without being infrastructure-focused.
  • Framework-specific is detected via the Framework Detection table (dependency-based), not directory patterns. Only present if a framework was identified.

Analysis Guidance (Beyond File Presence)

When performing LLM-driven codebase analysis (see coding-workflows:codebase-analysis skill), these per-stack guides indicate what to look for beyond file presence. Use these after identifying the stack via the tables above.

Python / FastAPI

  • Dependency injection: How Depends() is used -- shared session patterns, auth injection, config injection
  • Async patterns: Consistent async/await usage, background tasks (Celery, Dramatiq, or native)
  • Pydantic models: Request/response model organization, validation patterns, shared base models
  • Error handling: Custom exception handlers, error response format consistency
  • Database patterns: SQLAlchemy session management, Alembic migration conventions, repository vs direct query patterns

TypeScript / Next.js

  • Component boundaries: Server vs client component split, data fetching strategy (server actions, RSC, API routes)
  • State management: React Context, Zustand, Redux, or server-side state
  • Route organization: App router patterns, parallel routes, intercepting routes
  • Type safety: Shared type definitions, Zod validation, end-to-end type safety

Ruby / Rails

  • Service objects: Thin controllers + service objects vs fat models, command/operation patterns
  • ActiveRecord patterns: Scoping conventions, association patterns, callback usage
  • Background jobs: Sidekiq/GoodJob organization, retry strategies, job base class patterns
  • Testing: RSpec conventions (factories vs fixtures, shared examples, request spec patterns)

Rust / Actix or Axum

  • Error handling: thiserror/anyhow usage, error type hierarchy
  • State sharing: Arc<Mutex<T>> patterns, app state extractors
  • Middleware and extractors: Custom extractors, middleware chains
  • Async runtime: tokio patterns, spawned tasks, channel usage

Go

  • Interface design: Interface segregation, dependency injection patterns
  • Context propagation: Context usage across service boundaries, timeout patterns
  • Error wrapping: fmt.Errorf with %w, sentinel errors, custom error types
  • Goroutine safety: Mutex usage, channel patterns, sync.WaitGroup

Generic (Unlisted Stacks)

  • Entry point organization: Single vs multiple entry points, CLI vs server vs worker
  • Error handling approach: Exceptions, result types, error codes
  • Testing framework: Unit vs integration test organization, fixture patterns
  • Module boundaries: How the codebase separates concerns

Polyglot Projects

When multiple language files are detected (e.g., pyproject.toml and package.json):

  • Present all detected languages to the user
  • Ask which is the primary language
  • Framework detection runs against the selected primary language
  • Domain detection is language-agnostic (directory-based) and applies to all languages

When Detection Fails

If no project files are found or the technology stack cannot be determined, prompt the user for:

  1. Primary language
  2. Framework (if applicable)
  3. Key domains in the codebase (e.g., API, storage, auth)