AgentSkillsCN

bd-project-conventions

确保代码符合项目规范与结构要求。在搭建新文件、重构代码、配置环境,或排查导入/构建相关问题时使用此功能。

SKILL.md
--- frontmatter
name: bd-project-conventions
description: Ensures code compliance with project conventions and structure. Use when scaffolding new files, refactoring code, configuring environments, or troubleshooting import/build issues.

Project Conventions

This skill guides project structure, environment setup, and development conventions. Apply these standards when starting new projects, onboarding to existing codebases, or troubleshooting setup issues.

The user needs help with project setup, environment configuration, import issues, or understanding project structure. They may be starting fresh or debugging existing configuration.


Project Thinking

Before setting up or modifying project structure, understand the goals:

  • Consistency: Does this follow platform conventions others will recognize?
  • Separation: Are concerns properly separated (source, tests, config)?
  • Reproducibility: Can another developer set up identically?
  • Security: Are secrets and credentials properly handled?

CRITICAL: Follow platform conventions. Custom structures create friction for every new team member.

When This Applies

Use this skill when:

  • Creating a new project
  • Setting up a development environment
  • Troubleshooting import/module errors
  • Configuring environment variables
  • Understanding project structure
  • Onboarding to a new codebase

Root-Level Structure

Applies to: All software — Mobile, Web, Backend, Desktop, CLI, Libraries

At the root of the application, code is organized by feature. This ensures related code lives together and features remain modular and independently maintainable. The exact folder/module shape differs per platform, but the same feature boundaries apply.

Flutter (Dart)

code
/lib
  /common              # Shared foundations
  /authentication      # Feature
  /settings            # Feature
  /orders              # Feature
  ...

Android (Kotlin)

Guidance: Use Gradle modules or folders to represent feature boundaries.

code
/ (repo root)
  /app                 # Android application
  /common              # Shared foundations
  /authentication      # Feature module
  /settings            # Feature module
  ...

iOS (Swift)

Guidance: Represent feature boundaries using Swift packages (preferred) or Xcode modules/targets.

code
/ (repo root)
  /App                 # iOS application target
  /Common              # Shared foundations
  /Authentication      # Feature package/target
  /Settings            # Feature package/target
  ...

Python Backend

Guidance: Use packages/modules for feature boundaries.

code
/src
  /common              # Shared foundations
  /authentication      # Feature
  /orders              # Feature
  /payments            # Feature
  ...
/tests
  /authentication
  /orders
  ...

Node.js/TypeScript Backend

Guidance: Use folders or npm workspaces for feature boundaries.

code
/src
  /common              # Shared foundations
  /authentication      # Feature
  /orders              # Feature
  /payments            # Feature
  ...

Go Backend

Guidance: Use packages within internal/ for feature boundaries.

code
/cmd
  /server              # Entry point
/internal
  /common              # Shared foundations
  /authentication      # Feature
  /orders              # Feature
  /payments            # Feature
  ...

React/Vue/Angular Web

Guidance: Use feature folders within src.

code
/src
  /common              # Shared foundations
  /authentication      # Feature
  /dashboard           # Feature
  /settings            # Feature
  ...

The Common Module

Applies to: All platforms and software types

Common contains shared foundations used broadly across the app:

  • Design tokens and theming (UI apps)
  • Core utilities and helpers
  • Shared platform adapters
  • Shared business types/models
  • Cross-cutting concerns (logging, error handling)

CRITICAL: Keep Common small and stable. If something is feature-specific, it belongs in that feature.


Environment Configuration

Applies to: All projects with environment-specific settings

Environment File Pattern

Guidance:

  1. Create template: .env.example (committed to git)

    code
    # Database
    DATABASE_URL=postgres://user:pass@localhost:5432/db
    
    # API Keys (get from team lead)
    API_KEY=your-api-key-here
    
    # Feature Flags
    FEATURE_NEW_UI=false
    
  2. Create local config: .env (never committed)

    bash
    cp .env.example .env
    # Edit .env with real values
    
  3. Add to .gitignore:

    code
    .env
    .env.local
    .env.*.local
    

What Belongs in Environment Files

IncludeExclude
Database URLsHardcoded in source
API keysCommitted to git
Feature flagsProduction secrets in dev files
Service endpointsAnything that doesn't vary
Debug flags

Loading Environment Variables

PlatformMethod
Pythonpython-dotenv or environs
Node.jsdotenv package
Flutterflutter_dotenv or envied
Gogodotenv or viper

Dependency Management

Applies to: All projects

Lock Files

Guidance: Always commit lock files for reproducible builds.

PlatformLock FileCommand to Update
Pythonrequirements.lock or poetry.lockpip-compile or poetry lock
Node.jspackage-lock.jsonnpm install
Flutterpubspec.lockflutter pub get
Gogo.sumgo mod tidy
SwiftPackage.resolvedswift package resolve
RustCargo.lockcargo update

Dependency Organization

CategoryDescription
ProductionRequired at runtime
DevelopmentTesting, linting, building
OptionalFeature-specific extras

Import Conventions

Applies to: All projects with modules

General Rules

RuleRationale
Relative within packageCleaner, refactor-friendly
Absolute in testsTests import the package, not siblings
No path manipulationNever modify sys.path, import path, etc.
Barrel exportsClean public API (index.ts, init.py)

Import Order

Guidance: Group imports in this order:

code
1. Standard library / built-ins
2. Third-party packages
3. Local application imports
   - Absolute imports
   - Relative imports

Common Setup Issues

Applies to: Troubleshooting

Import/Module Errors

ErrorLikely CauseSolution
Module not foundPackage not installed in editable modepip install -e .
Cannot resolveMissing init.pyAdd empty init.py files
Circular importModules importing each otherRestructure or use lazy imports
No module named XWrong environmentActivate correct venv/node_modules

Build Errors

ErrorLikely CauseSolution
Version mismatchLock file out of syncDelete lock, reinstall
Missing dependencyNot in requirementsAdd and reinstall
Platform-specificOS-specific packageUse conditional dependencies

Anti-Patterns (NEVER use)

  • sys.path hacks: Never modify import paths programmatically
  • Hardcoded paths: Use relative paths or configuration
  • Secrets in code: Use environment variables
  • Missing lock files: Always commit lock files
  • Mixing test/prod: Keep test utilities out of production code
  • Custom project layouts: Follow platform conventions