home / skills / masanao-ohba / claude-manifests / functional-designer

functional-designer skill

/skills/php-cakephp/functional-designer

This skill designs functional architectures and detailed PHP/CakePHP specifications from requirements to guide development and ensure consistent, scalable

npx playbooks add skill masanao-ohba/claude-manifests --skill functional-designer

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
7.7 KB
---
name: functional-designer
description: Designs functional architecture and detailed specifications for PHP/CakePHP applications based on analyzed requirements
---

# Functional Designer

A specialized skill for creating detailed functional designs and technical specifications for PHP/CakePHP applications.

## Core Responsibilities

### 1. Functional Architecture Design

**Component Mapping:**
```yaml
Functional Component Design:
  Controllers:
    - name: [Controller]Controller
    - actions: [list of actions]
    - authentication: required|optional
    - authorization: role-based permissions

  Models:
    - Tables: [list of Table classes]
    - Entities: [list of Entity classes]
    - Associations: [relationships]
    - Validation: [rules]

  Views:
    - Templates: [list of .php files]
    - Elements: [reusable components]
    - Layouts: [page structures]

  Components:
    - Custom components needed
    - Third-party integrations
```

### 2. API Design Specification

**RESTful Endpoint Design:**
```yaml
API Endpoint:
  method: GET|POST|PUT|DELETE
  path: /api/v1/[resource]
  authentication: required|optional

  request:
    headers:
      Content-Type: application/json
      Authorization: Bearer [token]
    body:
      field1: type
      field2: type

  response:
    success:
      status: 200
      body: {data: [...]}
    error:
      status: 400|401|404|500
      body: {error: "message"}
```

### 3. Data Flow Design

**Request Lifecycle:**
```
1. Route → Controller
2. Controller → Authorization Check
3. Controller → Validation
4. Controller → Model/Service
5. Model → Database
6. Model → Entity
7. Controller → View/JSON Response
```

**Data Transformation:**
```php
Input Data → Validation → Business Logic → Entity → Output Format
```

### 4. CakePHP Design Patterns

**MVC Structure:**
```
src/
├── Controller/
│   ├── AppController.php
│   ├── User/
│   │   └── UsersController.php
│   └── Api/
│       └── UsersController.php
├── Model/
│   ├── Table/
│   │   └── UsersTable.php
│   └── Entity/
│       └── User.php
├── View/
│   └── User/
│       └── Users/
│           ├── index.php
│           ├── view.php
│           ├── add.php
│           └── edit.php
└── Service/
    └── UserService.php
```

### 5. Design Document Template

```markdown
# Functional Design: [Feature Name]

## 1. Overview
### Purpose
[Brief description of what this feature does]

### Scope
- In Scope: [what's included]
- Out of Scope: [what's not included]

## 2. Functional Components

### 2.1 Controllers
#### [Name]Controller
- **Purpose**: [description]
- **Actions**:
  - index(): List all records
  - view($id): Display single record
  - add(): Create new record
  - edit($id): Update existing record
  - delete($id): Remove record

### 2.2 Models
#### [Name]Table
- **Fields**:
  - id (integer, primary key)
  - name (string, required)
  - status (integer, default: 1)
  - created (datetime)
  - modified (datetime)

- **Associations**:
  - belongsTo: [Parent]
  - hasMany: [Children]

- **Validation Rules**:
  - name: notEmpty, maxLength(255)
  - email: email, unique

### 2.3 Business Logic
```php
// Pseudo-code for main logic
public function processOrder($data) {
    // 1. Validate input
    // 2. Calculate totals
    // 3. Check inventory
    // 4. Create order
    // 5. Send notifications
    // 6. Return result
}
```

## 3. Database Design

### Tables
```sql
CREATE TABLE orders (
    id INT PRIMARY KEY AUTO_INCREMENT,
    user_id INT NOT NULL,
    total DECIMAL(10,2),
    status INT DEFAULT 1,
    created DATETIME,
    modified DATETIME,
    FOREIGN KEY (user_id) REFERENCES users(id)
);
```

## 4. API Specification

### Endpoints
| Method | Path | Description |
|--------|------|-------------|
| GET | /api/orders | List orders |
| GET | /api/orders/{id} | Get order details |
| POST | /api/orders | Create order |
| PUT | /api/orders/{id} | Update order |
| DELETE | /api/orders/{id} | Delete order |

## 5. Security Considerations
- Authentication: JWT/Session
- Authorization: Role-based (Admin, User, Guest)
- Data Validation: Server-side validation for all inputs
- SQL Injection: Use ORM query builder
- XSS Prevention: Escape output in views

## 6. Performance Considerations
- Pagination for large datasets
- Eager loading for associations
- Query optimization
- Caching strategy
```

## Design Patterns

### 1. Service Layer Pattern
```php
// Service class for complex business logic
class OrderService
{
    private $Orders;
    private $Inventory;

    public function createOrder($data)
    {
        // Complex logic separated from controller
    }
}
```

### 2. Repository Pattern
```php
// Custom finder methods in Table class
class OrdersTable extends Table
{
    public function findPending(Query $query, array $options)
    {
        return $query->where(['status' => 'pending']);
    }
}
```

### 3. Event-Driven Design
```php
// Event listeners for decoupled components
EventManager::instance()->on(
    'Model.Order.afterCreate',
    function ($event, $order) {
        // Send notification
        // Update inventory
        // Log activity
    }
);
```

## Integration Patterns

### 1. Multi-Tenant Design
```php
// Company-specific data access
public function getCompanyOrders($companyId)
{
    $conn = $this->MessageDeliveryDbAccessor
        ->getUserMessageDeliveryDbConnection($companyId);

    $this->Orders->setConnection($conn);
    return $this->Orders->find()->all();
}
```

### 2. Plugin Integration
```yaml
Plugins to integrate:
  - Authentication: CakePHP/Authentication
  - Authorization: CakePHP/Authorization
  - PDF Generation: FriendsOfCake/CakePdf
  - Email: Built-in Mailer
```

### 3. Queue Processing
```php
// Async job processing
QueueManager::push(SendEmailJob::class, [
    'to' => $user->email,
    'template' => 'order_confirmation',
    'data' => $orderData
]);
```

## Output Examples

### Example 1: User Management Design
```yaml
Feature: User Management

Controllers:
  UsersController:
    - index: List users with pagination
    - add: Create user with role assignment
    - edit: Update user profile
    - delete: Soft delete with audit log

Models:
  UsersTable:
    fields: [id, email, password, role_id, status]
    associations:
      - belongsTo: Roles
      - hasMany: Orders
    validation:
      - email: unique, valid format
      - password: min 8 chars, complexity rules

Security:
  - Password hashing: bcrypt
  - Session management: 30 min timeout
  - Role-based access: Admin, Manager, User
```

### Example 2: Reporting Module Design
```yaml
Feature: Sales Reporting

Components:
  ReportGenerator:
    - generateMonthly(): Create monthly report
    - exportPdf(): Convert to PDF
    - sendEmail(): Email to stakeholders

Data Sources:
  - Orders table
  - OrderItems table
  - Products table

Performance:
  - Use database views for complex queries
  - Cache generated reports for 24 hours
  - Background job for large reports
```

## Quality Criteria

### Good Design:
- Clear separation of concerns
- Reusable components
- Scalable architecture
- Follows CakePHP conventions
- Testable code structure

### Poor Design:
- Business logic in controllers
- Direct database queries in views
- Tight coupling between components
- Ignoring framework conventions

## Best Practices

1. **Follow Conventions**: Use CakePHP naming conventions
2. **Keep Controllers Thin**: Move logic to models/services
3. **Use Behaviors**: Share functionality between models
4. **Implement Interfaces**: Define contracts for services
5. **Document Decisions**: Explain why, not just what

Remember: Good design makes implementation straightforward and maintenance easy.

Overview

This skill designs functional architecture and detailed specifications for PHP/CakePHP applications from analyzed requirements. It produces component maps, API specs, request lifecycles, data models, and implementation templates that follow CakePHP conventions. The output is actionable: controllers, models, views, services, API endpoints, and database DDL ready for handoff to developers.

How this skill works

I inspect feature requirements and translate them into a structured functional design: component breakdowns, REST API descriptions, data flow diagrams, and CakePHP directory patterns. I produce validation rules, associations, security and performance considerations, service/repository patterns, event hooks, and integration recommendations. Deliverables include a feature-level design document, example YAML/SQL/PHP snippets, and clear in/out scope for each feature.

When to use it

  • Defining features before development starts to reduce rework
  • Scoping API-first or backend-heavy projects in CakePHP
  • Refactoring legacy CakePHP apps to adopt service/repository patterns
  • Preparing handoff artifacts for frontend and QA teams
  • Designing multi-tenant or plugin-integrated architectures

Best practices

  • Follow CakePHP naming and file conventions to reduce friction
  • Keep controllers thin; push business rules into services or table classes
  • Define clear validation and authorization rules for every endpoint
  • Use ORM and query builders to prevent SQL injection and enable eager loading
  • Document design decisions, security controls, and performance trade-offs

Example use cases

  • User management feature: controllers, tables, validation, role-based access and JWT/session guidance
  • Order processing: OrderService pseudo-code, DB schema, API endpoints and event listeners for notifications
  • Reporting module: data sources, background job pattern, caching and export components
  • Multi-tenant data access: connection switching strategy and tenant-scoped queries
  • Plugin integration: recommended plugins for auth, authorization, PDF and queue processing

FAQ

What artifacts will I receive?

A functional design document with overview, component mapping, API spec, DB DDL, service patterns, sample code snippets and security/performance notes.

Do you produce implementation code?

I provide pseudo-code and concrete snippets (YAML, SQL, PHP) and clear developer instructions, but not full production implementations.