Skip to content

Commit a2a5531

Browse files
committed
コメント追加
1 parent ad8b27e commit a2a5531

File tree

1 file changed

+107
-39
lines changed

1 file changed

+107
-39
lines changed

CLAUDE.md

Lines changed: 107 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,166 @@
11
# CLAUDE.md
22

3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
3+
This document provides guidance for Claude Code (claude.ai/code) **and developers** working with code in this repository.
4+
5+
---
46

57
## Project Overview
68

7-
This is a WordPress plugin that integrates with ColorMe Shop (カラーミーショップ) API to display product information and generate product pages within WordPress. The plugin uses OAuth2 authentication and provides shortcodes for embedding product information.
9+
This is a WordPress plugin that integrates with the ColorMe Shop (カラーミーショップ) API to display product information and generate product pages within WordPress.
10+
It uses OAuth2 authentication and provides WordPress shortcodes for embedding product details.
11+
12+
---
813

914
## Development Commands
1015

1116
### Setup
17+
1218
```bash
1319
# Copy environment file and start Docker containers
1420
cp wp.env.sample wp.env
1521
docker-compose up -d
22+
23+
# Install PHP dependencies via Composer
24+
docker-compose run --rm composer install
1625
```
1726

27+
> After setup, activate the plugin from the WordPress admin dashboard.
28+
29+
---
30+
1831
### Testing
32+
1933
```bash
2034
# Run unit tests
2135
./tests/run.sh
2236

23-
# Run tests using Docker
24-
docker-compose run --rm wordpress bash -c "cd /var/www/html/wp-content/plugins/colormeshop-wp-plugin && ./vendor/bin/phpunit"
37+
# Run tests using Docker (WordPress environment)
38+
docker-compose run --rm wordpress bash -c "cd /var/www/html/wp-content/plugins/colormeshop-wp-plugin && ./vendor/bin/phpunit"
2539
```
2640

41+
- Tests use the WordPress test framework and VCR for recording/replaying HTTP requests
42+
- VCR fixtures are stored in `tests/fixtures/`
43+
- New API interactions can be recorded by switching VCR to record mode
44+
- Coverage reports exclude generated Swagger code
45+
46+
---
47+
2748
### Code Quality
49+
2850
```bash
2951
# Check coding standards (WordPress Coding Standards)
3052
docker-compose run composer vendor/bin/phpcs --standard=ruleset.xml
3153

32-
# Auto-fix code formatting issues
54+
# Auto-fix formatting issues
3355
docker-compose run composer vendor/bin/phpcbf --standard=ruleset.xml
3456
```
3557

58+
> Note: This plugin follows WordPress coding standards and naming conventions.
59+
> Claude should preserve these when suggesting code changes.
60+
61+
---
62+
3663
### Build and Deployment
64+
3765
```bash
38-
# Generate API client from ColorMe Shop API
66+
# Generate API client from ColorMe Shop API (Swagger/OpenAPI)
3967
make generate_api_client
4068

41-
# Build plugin zip file for distribution
69+
# Build plugin zip for distribution (output: ./dist/colormeshop-wp-plugin.zip)
4270
make
4371

4472
# Update autoload classmap after adding new classes
4573
docker-compose run --rm composer dump-autoload
4674
```
4775

76+
---
77+
4878
## Architecture
4979

5080
### Core Components
5181

52-
- **Plugin**: Main plugin class that handles WordPress hooks, shortcode registration, and DI container setup
53-
- **Admin**: WordPress admin interface for plugin configuration (OAuth settings, product page ID)
54-
- **Models**: Data models for Settings and Sitemap generation
55-
- **API Layer**: Wrapper around generated Swagger API client for ColorMe Shop API
56-
- **Shortcodes**: WordPress shortcodes for displaying products, images, options, and cart buttons
82+
- **Plugin**: Main orchestrator that registers hooks, shortcodes, and DI container
83+
- **Admin**: WordPress admin UI for plugin settings (OAuth credentials, page IDs)
84+
- **Models**: Internal models for plugin settings and sitemap generation
85+
- **API Layer**: Wrapper around Swagger-generated client for ColorMe Shop API
86+
- **Shortcodes**: Functions to embed product data, images, cart buttons via shortcodes
87+
88+
---
89+
90+
### Key File Structure
5791

58-
### Key Files
92+
| Path | Purpose |
93+
|-----------------------------|--------------------------------------------|
94+
| `src/class-plugin.php` | Plugin bootstrap and DI setup |
95+
| `src/class-admin.php` | Admin UI and setting page |
96+
| `src/Swagger/` | Auto-generated ColorMe API client |
97+
| `src/shortcodes/` | Shortcode definitions |
98+
| `src/models/` | Data models and logic |
99+
| `templates/` | PHP templates used in rendering |
59100

60-
- `src/class-plugin.php`: Main plugin orchestrator with DI container
61-
- `src/class-admin.php`: WordPress admin interface
62-
- `src/Swagger/`: Auto-generated API client from ColorMe Shop API
63-
- `src/shortcodes/`: WordPress shortcodes for product display
64-
- `src/models/`: Data models and business logic
65-
- `templates/`: PHP templates for rendering
101+
> Note: Filenames like `class-plugin.php` follow WordPress conventions — do not rename them.
66102
67-
### DI Container Structure
103+
---
68104

69-
The plugin uses Pimple for dependency injection. Key services:
70-
- `oauth2_client`: OAuth2 authentication client
71-
- `api.product_api`: Product API wrapper
72-
- `model.setting`: Plugin settings management
73-
- `swagger.configuration`: API configuration with access token
105+
### Dependency Injection (DI)
106+
107+
- The plugin uses [Pimple](https://pimple.symfony.com/) as a DI container.
108+
- Key service bindings:
109+
- `oauth2_client`: OAuth2 client instance
110+
- `api.product_api`: Product API abstraction
111+
- `model.setting`: WordPress options access wrapper
112+
- `swagger.configuration`: Swagger client configuration (access token injected)
113+
114+
---
74115

75116
### Database Integration
76117

77-
Settings are stored using WordPress options API under the key `colorme_wp_settings`.
118+
- Plugin settings are stored using the WordPress Options API under the key:
119+
120+
```
121+
colorme_wp_settings
122+
```
123+
124+
---
78125

79126
### API Integration
80127

81-
- Uses generated Swagger client for ColorMe Shop API v1
82-
- Implements OAuth2 flow with access token storage
83-
- Provides abstraction layer over raw API responses
84-
- Includes VCR fixtures for testing API interactions
128+
- Uses Swagger client generated from ColorMe Shop API v1
129+
- Authenticated via OAuth2 access token (user-provided)
130+
- Abstraction layer wraps raw API client for safer access
131+
- VCR (PHP-VCR) used to record HTTP interactions during tests
132+
133+
---
85134

86135
### WordPress Integration
87136

88-
- Registers custom rewrite rules for product pages and sitemaps
89-
- Uses WordPress hooks for title filtering and template redirection
90-
- Follows WordPress coding standards and file naming conventions
91-
- Supports mobile detection and custom templates
137+
- Custom rewrite rules for product pages and sitemap XML
138+
- Uses hooks for title filtering and template redirection
139+
- Supports device detection for rendering mobile-specific views
140+
- Template override support via standard WordPress theme hierarchy
141+
142+
---
143+
144+
## Claude Usage Tips
145+
146+
- When modifying shortcodes, ensure arguments are processed using `shortcode_atts()`
147+
- Always retrieve settings via the `model.setting` service rather than accessing options directly
148+
- When adding templates, place them in the `templates/` directory and reference with `include()`
149+
- When working on OAuth2 logic, ensure secure token storage using WP options and proper sanitization
150+
- Avoid modifying files in `src/Swagger/` directly — these are auto-generated
151+
152+
---
153+
154+
## Appendix
155+
156+
### External Dependencies
157+
158+
- WordPress ≥ 5.0
159+
- Composer (for dependency management)
160+
- Docker (for development environment)
161+
162+
---
92163

93-
## Testing
164+
## License
94165

95-
- PHPUnit with WordPress test framework
96-
- VCR for recording and replaying HTTP requests
97-
- Separate test classes mirror the source structure
98-
- Coverage reporting excludes generated Swagger code
166+
See `LICENSE` file in the root of this repository.

0 commit comments

Comments
 (0)