claudecode openspec 使用备忘

0x01 初始化目录结构

cd $work_dir
openspec init

0x02 更新项目基础信息

# Project Context

## Purpose
Next-generation web API project designed to provide a robust, scalable REST API foundation for modern applications. This project focuses on building enterprise-grade services with clean architecture patterns and comprehensive testing.

## Tech Stack
- **Backend**: Java 17+ with Spring Boot 3.x
- **API Style**: RESTful API with OpenAPI 3.0 documentation
- **Database**: MySQL, with mybatis-plus-spring-boot3-starter
- **Build Tool**: Maven
- **Testing**: JUnit 5, Mockito, Testcontainers
- **Documentation**: SpringDoc OpenAPI
- **Security**: Spring Security with JWT authentication
- **Validation**: Jakarta Bean Validation
- **Logging**: Logback with structured logging

## Project Conventions

### Code Style
- Follow Java standard conventions and Google Java Style Guide
- Use meaningful variable and method names (camelCase)
- Keep classes and methods focused on single responsibilities
- Use Lombok for reducing boilerplate code where appropriate
- Maintain 80-120 character line limits

### Architecture Patterns
- **Clean Architecture**: Separate concerns with distinct layers
- **Domain-Driven Design (DDD)**: Focus on business domains and bounded contexts
- **Dependency Injection**: Constructor-first pattern with Spring's DI container
- **Repository Pattern**: Abstraction over data access logic
- **Service Layer**: Business logic encapsulation
- **Controller Layer**: REST endpoint handling with proper HTTP semantics

### Testing Strategy
- **Unit Tests**: 80%+ coverage for business logic with JUnit 5 and Mockito
- **Integration Tests**: Test database operations and external dependencies with Testcontainers
- **API Tests**: Validate REST endpoints with MockMvc
- **Test Naming**: Use descriptive names that explain the scenario
- **Test Structure**: Arrange-Act-Assert pattern with clear test data setup

### Git Workflow
- **Main Branch**: `main` for production-ready code
- **Feature Branches**: `feature/description` for new functionality
- **Hotfix Branches**: `hotfix/description` for urgent fixes
- **Commit Messages**: Conventional Commits format (feat:, fix:, docs:, etc.)
- **Pull Requests**: Required for all changes with peer review

## Domain Context
This is a foundational web API project that can be adapted for various business domains. The architecture supports:
- Multi-tenant SaaS applications
- High-throughput transaction processing
- Real-time data synchronization
- Event-driven architectures (when needed)
- Microservices deployment patterns

## Important Constraints
- **Performance**: API responses should complete within 200ms for 95th percentile
- **Scalability**: Horizontal scaling with stateless service design
- **Security**: All endpoints require authentication except public health checks
- **Data Privacy**: Compliance with GDPR and data protection regulations
- **Availability**: 99.9% uptime target with proper error handling and retries
- **Maintainability**: Code should be understandable by new team members within 30 minutes

## External Dependencies
- **MySQL**: Primary database
- **Redis**: Caching and session storage (when needed)
- **Monitoring**: Application metrics and health check endpoints
- **File Storage**: Object storage integration for file management

0x03 创建需求

claude
 /openspec:proposal "创建spring boot工程,提供健康检测接口,不使用JPA。"

执行完成后,可以手动编辑内容。

0x04 查看需求列表

在claude 外面,工作目录下直接执行

openspec list

#Changes:
#  setup-spring-boot-project     0/29 tasks

0x05 提交需求任务

/openspec:apply setup-spring-boot-project

在执行过程中,可以查看进度

openspec view
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容