Add an iOS App Clip target to an Expo app. Use when the user mentions App Clip, AASA, apple-app-site-association, appclips, smart app banner, or wants to ship a lightweight iOS Clip invoked from a URL alongside their parent app.
中文简介正在准备中。当前显示原文说明。
Enforces modern TypeScript best practices for type-safe code, strict configuration, runtime validation, and clear type contracts. Use when writing or reviewing TypeScript/JavaScript code, configuring tsconfig.json, or when the user asks for TypeScript style guidance.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Apply these rules by default when touching TypeScript/JavaScript:
strict: true in tsconfig.json (most impactful change)unknown instead of any; narrow with type guardstsconfig.json (or confirm it is already strict).any with unknown + narrowing/guards.any leaks.Use the always-applied rule file in this folder:
typescript.mdc (authoritative TypeScript/JSX guidance; read when you need the full rule text)Essential tsconfig.json settings:
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"allowJs": true,
"checkJs": true
}
}
Use interfaces for object shapes and class contracts. Define in .d.ts or .ts files, reference via JSDoc in .js files.
interface UserProfile {
id: string;
name: string;
email: string;
age?: number;
}
Use type aliases for unions, intersections, and tuples.
type ID = string | number;
type UserRole = "admin" | "user" | "guest";
type Coords = [number, number];
any, Use unknownany bypasses all type checks. unknown forces narrowing before use.
❌ Bad:
function processData(data: any) {
console.log(data.foo.bar); // No type safety
}
✅ Good:
function processData(data: unknown) {
if (typeof data === 'object' && data !== null && 'foo' in data) {
const typed = data as { foo: { bar: string } };
console.log(typed.foo.bar);
}
}
TypeScript's checks are compile-time only. For external data (APIs, user input), implement runtime validation with type guards.
function isString(value: unknown): value is string {
return typeof value === 'string';
}
function isNumber(value: unknown): value is number {
return typeof value === 'number' && !isNaN(value);
}
interface Product {
id: string;
name: string;
price: number;
}
function isProduct(obj: unknown): obj is Product {
return (
typeof obj === 'object' && obj !== null &&
'id' in obj && typeof obj.id === 'string' &&
'name' in obj && typeof obj.name === 'string' &&
'price' in obj && typeof obj.price === 'number'
);
}
Prefer string literal unions over numeric enums for better type safety and simpler runtime representation.
❌ Bad:
enum UserStatus {
Active, // 0
Inactive, // 1
Pending // 2
}
✅ Good:
type UserStatus = 'active' | 'inactive' | 'pending';
// If enum is necessary, use const string enum:
const enum UserRole {
Admin = "admin",
User = "user",
Guest = "guest"
}
Use generics for reusable, type-safe functions and components.
function identity<T>(arg: T): T {
return arg;
}
const num = identity(123); // number
const str = identity("hello"); // string
Named exports promote explicit imports and easier refactoring.
❌ Bad:
export default class UserService { }
✅ Good:
export class UserService { }
export const DEFAULT_USER = { };
Group imports: libraries → absolute paths → relative paths. Sort alphabetically.
import React from 'react';
import { useSelector } from 'react-redux';
import { API_URL } from 'config/constants';
import { selectUser } from 'store/selectors';
import { Button } from './components/Button';
import { formatCurrency } from '../utils/formatters';
Example 1: Type guard for API response
Input: "Validate and process API response" Output:
interface ApiUser {
id: string;
name: string;
email: string;
}
function isApiUser(obj: unknown): obj is ApiUser {
return (
typeof obj === 'object' && obj !== null &&
'id' in obj && typeof obj.id === 'string' &&
'name' in obj && typeof obj.name === 'string' &&
'email' in obj && typeof obj.email === 'string'
);
}
async function fetchUser(id: string): Promise<ApiUser | null> {
const response = await fetch(`/api/users/${id}`);
const data: unknown = await response.json();
if (isApiUser(data)) {
return data;
}
return null;
}
Example 2: String literal union type
Input: "Status type with specific values" Output:
type OrderStatus = 'pending' | 'processing' | 'shipped' | 'delivered';
function updateOrderStatus(orderId: string, status: OrderStatus) {
// TypeScript ensures only valid status values
console.log(`Order ${orderId} -> ${status}`);
}
updateOrderStatus('123', 'shipped'); // ✅ OK
// updateOrderStatus('123', 'invalid'); // ❌ Type error
Example 3: Generic utility function
Input: "Reusable function that works with any array type" Output:
function getFirst<T>(items: T[]): T | undefined {
return items[0];
}
const firstNum = getFirst([1, 2, 3]); // number | undefined
const firstStr = getFirst(['a', 'b']); // string | undefined
Example 4: JSDoc types for JavaScript files
Input: "Type-check JavaScript file with JSDoc" Output:
// types.d.ts
export interface UserProfile {
id: string;
name: string;
email: string;
}
// user-service.js
/**
* @typedef {import('./types').UserProfile} UserProfile
*/
/**
* @param {UserProfile} user
* @returns {string}
*/
export function greetUser(user) {
return `Hello, ${user.name}!`;
}
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Add an iOS App Clip target to an Expo app. Use when the user mentions App Clip, AASA, apple-app-site-association, appclips, smart app banner, or wants to ship a lightweight iOS Clip invoked from a URL alongside their parent app.
中文简介正在准备中。当前显示原文说明。
Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
中文简介正在准备中。当前显示原文说明。
Add Agentation visual feedback toolbar to a Next.js project
中文简介正在准备中。当前显示原文说明。
Apple's approach to interface design and fluid, physical motion, translated for the web. Use when building or reviewing gesture-driven UI, spring animations, drag/swipe/sheet interactions, momentum and interruptible transitions, translucent materials and depth, typography (optical sizing, tracking, leading), reduced-motion, or the design foundations (feedback, spatial consistency, restraint) behind Apple-style interfaces.
中文简介正在准备中。当前显示原文说明。
Derive and implement first-principles audio-coupled haptic and kinetic UI feedback. Use when designing, reviewing, or coding haptics/audio for mobile apps, native iOS/Android, React Native/Expo, SwiftUI, games, detent pickers, toggles, sliders, page curls, scroll gestures, wallet/signature flows, Solana transactions, backend/realtime state changes, confirmations, settlements, and semantic UI events where feedback should follow signal math instead of ad hoc vibration calls.
中文简介正在准备中。当前显示原文说明。
Babysit a GitHub pull request during a user-approved monitoring window by polling review comments, CI checks/workflow runs, and mergeability state. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and report fresh review feedback. Use when the user asks Codex to monitor a PR, watch CI, handle review comments, or keep an eye on failures and feedback on an open PR.
中文简介正在准备中。当前显示原文说明。