npm package: @nohsangwoo/autofire
Description: AI-First Firebase app framework — Speak. Build. Deploy.
Author: nohsangwoo
Latest version: 0.1.4
Deprecated: This package has been renamed to 'clawfire'. Install clawfire instead: npx clawfire init

# Autofire

**AI-First Firebase App Framework — Speak. Build. Deploy.**

Autofire는 "말하면 완성되는 Firebase 앱 플랫폼"입니다. 코드를 작성하지 않고, AI(Claude Skills)에게 말하며 앱을 만듭니다.

## Features

- **Contract-based API** — Zod 스키마로 input/output 계약 정의
- **File-based Routing** — `app/routes/` 디렉터리 = API 경로
- **Auto Client Generation** — 타입 안전한 `api.xxx.yyy()` 클라이언트 자동 생성
- **Firebase-Only Stack** — Firestore, Auth, Functions, Hosting 완전 통합
- **Security by Default** — 입력 검증, CORS, Rate Limit, 로그 마스킹 기본 제공
- **AI Skills System** — `/autofire-*` 커맨드로 프로젝트 관리
- **API Playground** — 웹 기반 API 탐색기 내장
- **Auto Security Rules** — 모델 정의에서 Firestore Rules 자동 생성

## Quick Start

```bash
# 새 프로젝트 초기화
npx autofire init

# 또는 기존 프로젝트에 설치
npm install autofire
```

## Usage

### Define a Model

```typescript
// app/schemas/product.ts
import { defineModel } from "autofire";

export const Product = defineModel({
  collection: "products",
  fields: {
    name: { type: "string", required: true },
    price: { type: "number", required: true },
    category: { type: "string", enum: ["electronics", "clothing"] },
  },
  timestamps: true,
  rules: {
    read: "public",
    create: "role",
    createRoles: ["admin"],
  },
});
```

### Define an API

```typescript
// app/routes/products/list.ts
import { defineAPI, z } from "autofire";

export default defineAPI({
  input: z.object({
    category: z.string().optional(),
    limit: z.number().default(20),
  }),
  output: z.object({
    products: z.array(z.object({
      id: z.string(),
      name: z.string(),
      price: z.number(),
    })),
    hasMore: z.boolean(),
  }),
  meta: {
    description: "상품 목록 조회",
    auth: "public",
    tags: ["products"],
  },
  handler: async (input, ctx) => {
    // Your business logic here
    return { products: [], hasMore: false };
  },
});
```

### Server Setup (Firebase Functions)

```typescript
// functions/index.ts
import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import { createRouter, createAdminDB, createSecurityMiddleware } from "autofire/functions";

admin.initializeApp();
const db = createAdminDB(admin.firestore());

const router = createRouter({
  auth: admin.auth(),
  cors: ["https://myapp.web.app"],
  middleware: createSecurityMiddleware(),
});

// Register routes
import listProducts from "../app/routes/products/list";
router.register("/products/list", listProducts);

export const api = functions.https.onRequest((req, res) => {
  router.handleRequest(req as any, res as any);
});
```

### Client Usage

```typescript
// Generated api-client.ts provides typed access
import { api, configureClient } from "./generated/api-client";
import { getAuth } from "firebase/auth";

configureClient("https://us-central1-myapp.cloudfunctions.net", async () => {
  const user = getAuth().currentUser;
  return user ? user.getIdToken() : null;
});

const result = await api.products.list({ category: "electronics", limit: 10 });
```

## Project Structure

```
app/
  routes/           API route handlers (file-based routing)
  schemas/          Model definitions (Firestore collections)
generated/          Auto-generated files (DO NOT EDIT)
  api-client.ts     Typed API client
  manifest.json     API manifest
functions/          Firebase Functions entry point
public/             Static files for Firebase Hosting
firebase.json       Firebase config
firestore.rules     Firestore security rules
autofire.config.ts  Autofire configuration
```

## AI Skills (Claude Code)

| Command | Description |
|---------|-------------|
| `/autofire-init` | Initialize project / connect Firebase |
| `/autofire-model` | Create/modify data models |
| `/autofire-api` | Create/modify APIs |
| `/autofire-auth` | Configure authentication |
| `/autofire-deploy` | Deploy to Firebase |
| `/autofire-diagnose` | Diagnose and fix issues |

## Auth Levels

| Level | Description |
|-------|-------------|
| `public` | No authentication required |
| `authenticated` | Login required |
| `role` | Specific role required |
| `reauth` | Recent re-authentication required |

## Exports

| Path | Description |
|------|-------------|
| `autofire` | Core types, defineAPI, defineModel, Zod |
| `autofire/functions` | Server-side: Router, DB, Auth, Security |
| `autofire/client` | Client-side: Auth helpers |
| `autofire/admin` | Admin: Rules, Indexes, User management |
| `autofire/codegen` | Code generation utilities |
| `autofire/playground` | Playground HTML generator |

## Tech Stack (Fixed)

- **DB**: Firestore
- **Auth**: Firebase Auth
- **Hosting**: Firebase Hosting
- **Backend**: Firebase Functions
- **Schema**: Zod
- **Language**: TypeScript

## License

MIT