本文へ移動
cccskills
無料GitHub で公開

code

Use when writing TypeScript/React code - covers type safety, component patterns, and file organization

日本語の概要は準備中です。原文の説明を表示しています。

trycompai/compスター 2,058(GitHub 2,058 + cccskills 0)

実行スコア 未検証

インストール方法を見る

含まれるファイル(1)

  • SKILL.md3.6 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Source Cursor rule: .cursor/rules/code.mdc. Original Cursor alwaysApply: false.

Code Standards

TypeScript

No any, No Unsafe Casts

// ✅ Validate with zod
const TaskSchema = z.object({ id: z.string(), title: z.string() });
const task = TaskSchema.parse(response.data);

// ✅ Use unknown and narrow
const parseResponse = (data: unknown): Task => {
  if (!isTask(data)) throw new Error('Invalid');
  return data;
};

// ❌ Never
const data: any = fetchData();
const task = response as Task;
const name = user!.name;
// @ts-ignore

Generics Over Any

// ✅ Generic
const first = <T>(items: T[]): T | undefined => items[0];

// ❌ Any
const first = (items: any[]): any => items[0];

React Patterns

Named Exports, PascalCase

// ✅ Named export, PascalCase file
// TaskCard.tsx
export function TaskCard({ task }: TaskCardProps) { ... }

// ❌ Default export, lowercase
export default function taskCard() { ... }

Derive State, Avoid useEffect

// ✅ Derived
const completedCount = tasks.filter(t => t.completed).length;

// ❌ Synced state
const [count, setCount] = useState(0);
useEffect(() => {
  setCount(tasks.filter(t => t.completed).length);
}, [tasks]);

When useEffect IS Appropriate

// External subscriptions
useEffect(() => {
  const sub = eventSource.subscribe(handler);
  return () => sub.unsubscribe();
}, []);

// DOM measurements
useEffect(() => {
  setHeight(ref.current?.getBoundingClientRect().height);
}, []);

Toasts with Sonner

import { toast } from 'sonner';

toast.success('Task created');
toast.error('Failed to save');
toast.promise(saveTask(), {
  loading: 'Saving...',
  success: 'Saved!',
  error: 'Failed',
});

File Structure

Colocate at Route Level

app/(app)/[orgId]/tasks/
├── page.tsx              # Server component
├── components/
│   └── TaskList.tsx      # Client component
├── hooks/
│   └── useTasks.ts       # SWR hook
└── data/
    └── queries.ts        # Server queries

Share Only When Reused 3+ Times

src/components/shared/    # Cross-page components
src/hooks/                # Shared hooks (useApiSWR, useDebounce)

Code Quality

File Size Limit: 300 Lines

Split large files into focused components.

Named Parameters for 2+ Args

// ✅ Named
const createTask = ({ title, assigneeId }: CreateTaskParams) => { ... };
createTask({ title: 'Review PR', assigneeId: user.id });

// ❌ Positional
const createTask = (title: string, assigneeId: string) => { ... };
createTask('Review PR', user.id); // What's the 2nd param?

Early Returns

// ✅ Early return
function processTask(task: Task | null) {
  if (!task) return null;
  if (task.deleted) return null;
  return <TaskCard task={task} />;
}

// ❌ Nested
function processTask(task) {
  if (task) {
    if (!task.deleted) {
      return <TaskCard task={task} />;
    }
  }
  return null;
}

Event Handler Naming

// ✅ Prefix with "handle"
const handleClick = () => { ... };
const handleSubmit = (e: FormEvent) => { ... };
const handleTaskCreate = (task: Task) => { ... };

Accessibility

// Interactive elements need keyboard support
<div
  role="button"
  tabIndex={0}
  onClick={handleClick}
  onKeyDown={(e) => e.key === 'Enter' && handleClick()}
  aria-label="Delete task"
>
  <TrashIcon />
</div>

// Form inputs need labels
<label htmlFor="task-name">Task Name</label>
<input id="task-name" type="text" />

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

The contract every new or modified API endpoint must follow so it is correct for the public OpenAPI spec, the MCP server (npm @trycompai/mcp-server), the ValidationPipe, and the docs. Triggers on "new endpoint", "add API", "new DTO", "@Body", "@RequirePermission", "MCP tool", "edit controller in apps/api", "OpenAPI", or whenever editing controllers under apps/api/src/.

日本語の概要は準備中です。原文の説明を表示しています。

trycompai/comp2,0582026年10月24日 更新

Audit & fix design system usage — migrate @trycompai/ui and lucide-react to @trycompai/design-system

日本語の概要は準備中です。原文の説明を表示しています。

trycompai/comp2,0582026年10月24日 更新

Audit & fix hooks and API usage patterns — eliminate server actions, raw fetch, and stale patterns

日本語の概要は準備中です。原文の説明を表示しています。

trycompai/comp2,0582026年10月24日 更新

Audit & fix RBAC and audit log compliance in API endpoints and frontend components

日本語の概要は準備中です。原文の説明を表示しています。

trycompai/comp2,0582026年10月24日 更新

Audit & fix unit tests for permission-gated components

日本語の概要は準備中です。原文の説明を表示しています。

trycompai/comp2,0582026年10月24日 更新

Configure Better Auth server and client, set up database adapters, manage sessions, add plugins, and handle environment variables. Use when users mention Better Auth, betterauth, auth.ts, or need to set up TypeScript authentication with email/password, OAuth, or plugin configuration.

日本語の概要は準備中です。原文の説明を表示しています。

trycompai/comp2,0582026年10月24日 更新

trycompai のスキルをすべて見る

このスキルの問題を報告する