These practices assist in building scalable, secure, and performant applications on Harper. They are aimed at developers involved in schema design, API management, and application deployment.
$ npx skills add https://github.com/harperfast/skills --skill harper-best-practicesThis skill provides structured guidelines for building applications on Harper, a backend platform. It covers schema design and data modeling, automatic API generation and querying, authentication and session handling, custom resource creation, and deployment to Harper Fabric. The skill organizes rules by priority—from schema and data design through infrastructure operations—helping developers make decisions that impact scalability and security. Reference these practices when designing database schemas, implementing REST or WebSocket APIs, handling authentication, optimizing data storage with vectors and blobs, or preparing applications for production deployment.
Install via the command: `$ npx skills add https://github.com/harperfast/skills --skill harper-best-practices`
Defining or modifying database schemas
Implementing or extending REST/WebSocket APIs
Handling authentication and session management
Working with custom resources and extensions
$ npx skills add https://github.com/harperfast/skills --skill harper-best-practicesgit clone https://github.com/harperfast/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Generate Harper best practices for [COMPONENT_TYPE] in [INDUSTRY]. Focus on [SPECIFIC_GOAL, e.g., security, scalability, or performance]. Include examples for [SCENARIO, e.g., high-traffic API endpoints or multi-tenant databases].
# Harper Best Practices for Secure API Design in Healthcare
## 1. Authentication & Authorization
- **Use OAuth 2.0** with JWT for API access. Avoid API keys for user-facing endpoints.
- **Example**: For a patient portal API, implement:
```http
POST /oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id=healthapp-patient-portal&client_secret=XYZ123&scope=read:patient_data
```
- **Role-based access control (RBAC)**: Assign permissions like `patient:read`, `doctor:write`, and `admin:full` to API endpoints.
## 2. Data Validation
- **Validate all inputs** using Harper’s schema constraints (e.g., `NOT NULL`, `ENUM`, or custom validators).
- **Example**: Reject malformed HL7 FHIR data with:
```json
{
"error": "InvalidPatientID",
"message": "Patient ID must be a 10-digit numeric value.",
"code": 400
}
```
## 3. Rate Limiting
- **Implement Harper’s rate limiter** with a sliding window for high-traffic endpoints (e.g., `/api/patient/{id}/records`).
- **Example**: Limit to 100 requests/minute per user:
```sql
CREATE POLICY rate_limit_policy ON api_requests
FOR SELECT USING (current_timestamp - created_at < interval '1 minute' AND user_id = current_user_id)
WITH CHECK (count(*) < 100);
```
## 4. Logging & Monitoring
- **Log all API requests** with metadata (e.g., `user_id`, `endpoint`, `response_time`, `status_code`).
- **Example**: Use Harper’s structured logging to track:
```json
{
"timestamp": "2024-05-20T14:30:00Z",
"level": "INFO",
"service": "patient-api",
"user_id": "pat_12345",
"endpoint": "/api/patient/12345/prescriptions",
"response_time_ms": 45,
"status_code": 200
}
```
## 5. Caching
- **Cache frequently accessed data** (e.g., patient demographics) using Harper’s Redis integration.
- **Example**: Cache patient records for 5 minutes with:
```sql
SELECT * FROM patient_data WHERE id = $1;
-- Cache result in Redis with key: `patient_data:12345`
```Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan