Claude Skills Guide

Building CCPA-Compliant Applications with Claude Code

The California Consumer Privacy Act (CCPA) and its successor, the California Privacy Rights Act (CPRA), impose specific obligations on businesses that handle personal information of California residents. For developers building applications that serve US users, implementing CCPA compliance requires careful attention to data handling practices, user rights mechanisms, and disclosure requirements. This guide shows practical approaches to building CCPA-compliant systems using Claude Code and its ecosystem of skills.

Understanding CCPA Requirements for Code

CCPA grants California residents four primary rights: the right to know what personal information is collected, the right to delete that information, the right to opt out of data sales, and the right to non-discrimination for exercising these rights. Your code needs to support all four rights systematically.

Before writing any compliance code, document what personal information your application collects. Create a simple inventory that tracks data categories, collection points, storage locations, and processing purposes. The supermemory skill helps maintain persistent context across Claude Code sessions, allowing you to build and update this inventory as your application evolves.

Automating Data Subject Requests

CCPA requires businesses to respond to consumer requests within 45 days. Automating these responses reduces manual effort and ensures consistent compliance.

Build a request handler that processes different types of CCPA requests:

// ccpa-request-handler.ts
interface CCPARequest {
  requestType: 'know' | 'delete' | 'opt-out' | 'correct';
  requesterIdentity: string;
  requestDate: Date;
  deadline: Date;
}

class CCPARequestHandler {
  async processRequest(request: CCPARequest): Promise<CCPAResponse> {
    const deadline = new Date(request.requestDate);
    deadline.setDate(deadline.getDate() + 45);
    
    switch (request.requestType) {
      case 'know':
        return this.handleKnowRequest(request.requesterIdentity);
      case 'delete':
        return this.handleDeleteRequest(request.requesterIdentity);
      case 'opt-out':
        return this.handleOptOutRequest(request.requesterIdentity);
      case 'correct':
        return this.handleCorrectionRequest(request.requesterIdentity);
    }
  }
  
  private async handleKnowRequest(identity: string): Promise<CCPAResponse> {
    const data = await this.dataInventory.getUserData(identity);
    return {
      personalInformation: data,
      categoriesCollected: data.map(d => d.category),
      businessPurpose: data.map(d => d.purpose),
      thirdPartySharing: await this.getSharingPartners(identity)
    };
  }
}

The tdd skill helps you write tests for these request handlers before implementation, ensuring your compliance logic works correctly from the start.

Implementing Data Minimization

CCPA encourages data minimization—collecting only what you need. Review your data collection points and remove unnecessary fields.

Use the frontend-design skill when building user-facing forms to ensure you’re only requesting essential information. Every field should have a documented business justification.

// Example: Minimal data collection
const userRegistrationSchema = {
  required: ['email', 'password'],
  optional: ['name', 'phone']  // Document why each optional field exists
};

// Validate against business necessity
function validateDataMinimization(schema, collectedData) {
  const unnecessaryFields = Object.keys(collectedData).filter(
    field => !schema.required.includes(field) && 
             !schema.optional.includes(field)
  );
  
  if (unnecessaryFields.length > 0) {
    throw new Error(`Collecting unnecessary data: ${unnecessaryFields.join(', ')}`);
  }
}

Building Opt-Out Mechanisms

The right to opt out of data sales is a core CCPA requirement. If your application sells personal information—or shares it for cross-context advertising—you must provide a clear opt-out mechanism.

Implement a global opt-out flag in your user data model:

# user_preferences.py
class UserPrivacyPreferences:
    def __init__(self, user_id: str):
        self.user_id = user_id
        self.opt_out_sale = False
        self.opt_out_sharing = False
        self.opt_out_analytics = False
        self.preferences_updated = None
    
    def apply_opt_out(self, opt_out_type: str) -> bool:
        if opt_out_type == 'sale':
            self.opt_out_sale = True
        elif opt_out_type == 'sharing':
            self.opt_out_sharing = True
        elif opt_out_type == 'analytics':
            self.opt_out_analytics = True
        
        self.preferences_updated = datetime.utcnow()
        return True
    
    def check_permission(self, action: str) -> bool:
        if action == 'sell_data' and self.opt_out_sale:
            return False
        if action == 'share_data' and self.opt_out_sharing:
            return False
        if action == 'analytics' and self.opt_out_analytics:
            return False
        return True

Privacy Policy Automation

CCPA requires specific disclosures in your privacy policy, including categories of information collected, purposes for collection, and categories of third parties with whom you share data. The pdf skill can help generate standardized policy documents, while the docx skill assists with maintaining internal compliance documentation.

Generate a dynamic privacy notice that reflects your actual data practices:

// privacy-notice-generator.js
function generatePrivacyNotice(companyData, userData) {
  const notice = {
    effectiveDate: new Date(),
    informationCollected: mapCategories(companyData.dataTypes),
    purposes: companyData.processingPurposes,
    sharingCategories: companyData.thirdPartyCategories,
    userRights: [
      'Right to know what personal information is collected',
      'Right to delete personal information',
      'Right to opt out of sale or sharing of personal information',
      'Right to non-discrimination'
    ],
    contactInformation: companyData.privacyContact
  };
  
  return notice;
}

Testing Compliance Workflows

Use the tdd skill to build comprehensive test coverage for your CCPA implementation:

// ccpa-compliance.test.js
describe('CCPA Compliance', () => {
  test('responds to deletion request within 45 days', async () => {
    const request = { type: 'delete', userId: 'user123', date: new Date() };
    const response = await handler.processRequest(request);
    
    expect(response.completed).toBe(true);
    expect(response.completionDate - request.date).toBeLessThan(45 * 24 * 60 * 60 * 1000);
  });
  
  test('honors opt-out before selling data', async () => {
    const user = await User.find('user123');
    user.privacyPreferences.applyOptOut('sale');
    await user.save();
    
    const canSell = checkCanSellData('user123');
    expect(canSell).toBe(false);
  });
  
  test('provides complete data inventory on know request', async () => {
    const response = await handler.processRequest({ type: 'know', userId: 'user123' });
    
    expect(response.personalInformation).toBeDefined();
    expect(response.categoriesCollected).toBeInstanceOf(Array);
    expect(response.thirdPartySharing).toBeDefined();
  });
});

Documentation and Audit Trails

Maintain logs of CCPA requests and your responses. This documentation proves compliance during audits.

-- CCPA request audit log
CREATE TABLE ccpa_requests (
  id SERIAL PRIMARY KEY,
  request_id UUID NOT NULL,
  user_id VARCHAR(255) NOT NULL,
  request_type VARCHAR(50) NOT NULL,
  request_date TIMESTAMP NOT NULL,
  completion_date TIMESTAMP,
  status VARCHAR(50) NOT NULL,
  response_data JSONB,
  processed_by VARCHAR(255)
);

CREATE INDEX idx_ccpa_requests_user ON ccpa_requests(user_id);
CREATE INDEX idx_ccpa_requests_date ON ccpa_requests(request_date);

The supermemory skill helps maintain project context, making it easier to track how privacy requirements evolve throughout development.

Integrating Privacy into Development Workflow

Make CCPA compliance part of your standard development process:

  1. Add privacy review to your pull request checklist
  2. Include CCPA requirements in your claude.md project file
  3. Use the tdd skill for test-driven privacy feature development
  4. Document data flows when adding new features
  5. Review third-party integrations for CCPA implications

Building CCPA compliance into your development workflow from the start is far more effective than retrofitting controls later. Claude Code skills like supermemory, tdd, frontend-design, pdf, and docx provide practical tools for implementing and maintaining privacy compliance throughout your project’s lifecycle.

Built by theluckystrike — More at zovo.one