---
title: Extension Camera Skill for Claude Code
canonical: https://skillselion.com/skills/caffeinelabs/skills/extension-camera
content_type: text/markdown
description: extension-camera is a Caffeine AI Build skill that adds web-camera preview and photo capture through the prefabricated useCamera React hook.
---

# Extension Camera Skill

Title: Extension Camera Skill for Claude Code

> extension-camera is a Caffeine AI Build skill that adds web-camera preview and photo capture through the prefabricated useCamera React hook.

Canonical: https://skillselion.com/skills/caffeinelabs/skills/extension-camera

extension-camera is a Caffeine AI Build skill that adds web-camera preview and photo capture through the prefabricated useCamera React hook.

The extension-camera skill adds web-camera access to Caffeine AI applications through a prefabricated, non-modifiable useCamera React hook from @caffeineai/camera. The hook exposes CameraConfig for facingMode, resolution, quality, and format, plus CameraError types for permission, not-supported, not-found, unknown, and timeout failures. UseCameraReturn provides isActive, isSupported, error, isLoading, currentFacingMode, startCamera, stopCamera, capturePhoto, switchCamera, retry, videoRef, and canvasRef. Docs require always showing a camera preview with explicit non-zero dimensions and a capture button, responsive layout with width 100% and stable aspect ratio, proper error display, and disabled controls until initialization completes. On desktop, camera switching should be avoided because only environment facing mode works reliably. The npm dependency is @caffeineai/camera at ~0.1.1 and no Caffeine subscription tier is required. Use when building Caffeine AI frontends that need photo capture, preview streaming, front or rear camera selection on mobile, and structured error handling without rewriting MediaStream plumbing.

## Key facts

- Installs: 31,909
- GitHub stars: 2
- Author: caffeinelabs
- Repository: caffeinelabs/skills
- Works in Grok Bot: yes
- Install command: `npx skills add https://github.com/caffeinelabs/skills --skill extension-camera`
- Last updated: November 16, 2026

## What Extension Camera does

Caffeine AI extension adding web-camera photo capture, preview streaming, camera switching, and error handling via a prefabricated React hook.

How do Caffeine AI frontends access device cameras with preview, capture, switching, and clear error states without custom MediaStream code?

A React camera component with video preview, capturePhoto File output, switchCamera support, and typed error handling wired through @caffeineai/camera.

Best for: Caffeine AI projects needing mobile or web photo capture with responsive preview layout and permission-aware error messaging.

Not for: Non-Caffeine React apps, desktop apps needing front-camera switching, or flows that skip visible preview and capture controls.

- Prefabricated useCamera hook from @caffeineai/camera cannot be modified by app code
- CameraConfig supports facingMode, resolution, quality, and jpeg/png/webp capture formats
- Structured CameraError types cover permission, not-supported, not-found, unknown, and timeout
- Docs mandate visible preview, capture button, non-zero dimensions, and disabled controls until ready
- Desktop guidance limits switching; only environment facing mode works reliably on desktop

## SKILL.md

## Camera
Camera extension for [Caffeine AI](https://caffeine.ai?utm_source=caffeine-skill&utm_medium=referral).

### Overview

This skill adds web-camera access via a prefabricated React hook. Supports photo capture, camera switching, and error handling.

## Frontend

For camera support:

There is a prefabricated React hook `@caffeinelabs/camera/hooks/useCamera.ts` that cannot be modified.

```typescript filepath=@caffeinelabs/camera/hooks/useCamera.ts
import { RefObject } from 'react';

export interface CameraConfig {
  // Camera facing mode - 'user' for front camera, 'environment' for back camera
  facingMode?: 'user' | 'environment';
  // Ideal video width and height in pixels
  width?: number;
  height?: number;
  // Image quality for capture (0-1, where 1 is highest quality)
  quality?: number;
  format?: 'image/jpeg' | 'image/png' | 'image/webp';
}

export interface CameraError {
  type: 'permission' | 'not-supported' | 'not-found' | 'unknown' | 'timeout';
  message: string;
}

export interface UseCameraReturn {
  // Whether camera is currently active and streaming
  isActive: boolean;
  // Whether camera is supported in current browser (null while checking)
  isSupported: boolean | null;
  // Current error state, if any
  error: CameraError | null;
  // Whether camera is initializing, starting, switching, or stopping
  isLoading: boolean;
  currentFacingMode: 'user' | 'environment';
  
  // Returns true on success
  startCamera: () => Promise<boolean>;
  stopCamera: () => Promise<void>;
  capturePhoto: () => Promise<File | null>;
  // Returns true on success
  switchCamera: () => (newFacingMode?: 'user' | 'environment') : Promise<boolean>;
  // Returns true on success
  retry: () => Promise<boolean>;
  
  // Ref to attach to video element for camera preview
  videoRef: RefObject<HTMLVideoElement>;
  // Ref to canvas element used for photo capture (can be hidden)
  canvasRef: RefObject<HTMLCanvasElement>;
}

export declare function useCamera(config?: CameraConfig): UseCameraReturn;
```

Usage example:

```
import { useCamera } from '@caffeineai/camera';

function CameraComponent() {
    const { 
        isActive, 
        isSupported, 
        error, 
        isLoading,
        startCamera, 
        stopCamera, 
        capturePhoto,
        switchCamera,
        videoRef, 
        canvasRef 
    } = useCamera({ 
        autoStart: true,
        facingMode: 'environment' 
    });

    if (isSupported === false) {
        return <div>Camera not supported</div>;
    }

    return (
        <div>
            <video 
                ref={videoRef} 
                style={{ width: '100%', height: 'auto' }}
                playsInline
                muted
            />
            <canvas ref={canvasRef} style={{ display: 'none' }} />
            
            {error && <div>Error: {error.message}</div>}
            
            <div>
                <button onClick={startCamera} disabled={isLoading || isActive}>
                    Start Camera
                </button>
                <button onClick={stopCamera} disabled={isLoading || !isActive}>
                    Stop Camera
                </button>
                <button onClick={switchCamera} disabled={isLoading || !isActive}>
                    Switch Camera
                </button>
                <button onClick={capturePhoto} disabled={!isActive}>
                    Take Photo
                </button>
            </div>
        </div>
    );
}
```

Always place a capture button on camera preview!
Always show a camera preview when the user opens the camera
On desktop, make sure that camera cannot be switched. Only 'environment' is working.
Properly display camera error messages in the app.
Do not make camera buttons clickable until the camera is fully initialized and ready.
Ensure the camera preview has explicit, non-zero dimensions (fixed height, min-height, or an aspect-ratio wrapper) so it never collapses due to layout.
Make the preview responsive across screen sizes (e.g., width: 100% with a stable aspect ratio).

## Extension Camera FAQ

### Can application code modify the useCamera hook?

No. Docs state the prefabricated React hook @caffeinelabs/camera/hooks/useCamera.ts cannot be modified.

### What camera UX rules are mandatory?

Always show a preview with explicit non-zero dimensions, include a capture button, display errors, and disable controls until initialization completes.

### Should desktop apps allow camera switching?

No. On desktop only environment facing mode works reliably, so switching should be disabled.

### Is Extension Camera safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

## Machine access

- [Sitemap](https://skillselion.com/sitemap.xml)
- [llms.txt](https://skillselion.com/llms.txt)
- [llms-full.txt](https://skillselion.com/llms-full.txt)
- [Developer resources](https://skillselion.com/developers)
- [OpenAPI spec](https://skillselion.com/openapi.json)
- [MCP handshake](https://skillselion.com/.well-known/mcp)
- [API catalog](https://skillselion.com/.well-known/api-catalog)
- [AI catalog](https://skillselion.com/.well-known/ai-catalog.json)
- [Pricing](https://skillselion.com/pricing.md)
- [Auth](https://skillselion.com/auth.md)
- [AGENTS.md](https://skillselion.com/AGENTS.md)
- [Contact](https://skillselion.com/contact)
- [Home](https://skillselion.com/)
