writing-typescript-code
БесплатноБез исполняемых скриптовНе проверенProvides TypeScript and React coding standards for this repository. Use when writing or modifying TypeScript code, creating React components, implementing…
от microsoft-foundry★ 137 звёзд на GitHubОб этом скилле
TypeScript Coding Standards
Goal: Write type-safe React components with proper MSAL integration
Hot Module Replacement (HMR) Workflow
The frontend runs with Vite HMR. When you edit TypeScript/React code:
- Save the file - Vite instantly updates the browser (no refresh needed)
- Check the terminal - Look for HMR updates in the "Frontend: React Vite" terminal
- State is preserved - React state persists through most edits
VS Code Tasks (use Run Task command or check terminal panel):
Frontend: React Vite- Runsnpm run devwith HMR enabled- Logs are visible directly in VS Code terminal
No restart needed - Just edit, save, and see changes instantly in the browser.
Testing changes: Use Playwright browser tools to:
- Navigate to http://localhost:5173
- Check browser console logs for state transitions and errors
- Inspect network requests for API validation
TypeScript Config
Enable strict mode + explicit types (avoid any):
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true
}
}
React Components
Use functional components + hooks + typed props:
interface MessageProps {
message: string;
sender: 'user' | 'agent';
}
function Message({ message, sender }: MessageProps) {
return <div className={`msg-${sender}`}>{message}</div>;
}
MSAL Pattern
Always: Try silent first, fallback to popup:
try {
const { accessToken } = await instance.acquireTokenSilent({
...tokenRequest,
account: accounts[0]
});
return accessToken;
} catch {
const { accessToken } = await instance.acquireTokenPopup(tokenRequest);
return accessToken;
}
Environment Variables
CRITICAL: Access at module level only (build-time replacement):
// ✅ Correct - module level
const clientId = import.meta.env.VITE_ENTRA_SPA_CLIENT_ID;
// ❌ Wrong - inside function (won't work after build)
function getClientId() {
return import.meta.env.VITE_ENTRA_SPA_CLIENT_ID;
}
Available variables:
VITE_ENTRA_SPA_CLIENT_ID- Entra app client IDVITE_ENTRA_TENANT_ID- Azure tenant ID
State Management
Use useState (local) or Context API (shared):
const [messages, setMessages] = useState<Message[]>([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<Error | null>(null);
Memoization Patterns
Use useMemo and useCallback for expensive computations and stable references:
// Memoize computed values
const isAuthenticated = useMemo(
() => accounts.length > 0,
[accounts.length]
);
// Memoize callbacks to prevent child re-renders
const getAccessToken = useCallback(async () => {
// ... token acquisition logic
}, [instance, accounts]);
// Return memoized object for stable reference
return useMemo(
() => ({ getAccessToken, isAuthenticated, user }),
[getAccessToken, isAuthenticated, user]
);
API Calls
Include Authorization header + use async/await:
const response = await fetch('/api/endpoint', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (!response.ok) throw new Error(`API error: ${response.status}`);
npm Dependencies
frontend/.npmrc sets legacy-peer-deps=true automatically — no flag needed when running from frontend/.
Gotcha: legacy-peer-deps skips automatic peer dependency installation. If a package requires peer deps, add them explicitly to package.json.
Example: @lexical/yjs requires yjs as a peer dependency. Since peer deps aren't auto-installed, yjs must be in package.json directly.
Before committing package changes, verify with:
npm ci # Fails if lock file is out of sync with package.json
Common Mistakes
- ❌ Accessing
import.meta.env.*in functions - ❌ Calling hooks conditionally or in loops
- ❌ Using
anytype - ❌ Storing tokens in component state
- ❌ Running
npm installoutsidefrontend/(misses.npmrcconfig) - ❌ Missing memoization in custom hooks (causes infinite re-renders)
- ❌ Returning new objects from hooks without
useMemo
Project-Specific: Architecture
| Concern | Implementation |
|---|---|
| State Management | Centralized Context + useReducer (AppContext) with discriminated action union |
| Authentication | MSAL redirect flow; silent token refresh; useAuth hook |
| Chat Streaming | SSE in ChatService with abort controllers for cancellation |
| Accessibility | Live region (aria-live), aria labels, focus management |
| Logging | Dev-only diff-based logger |
Project-Specific: Key Components
| Component | Purpose |
|---|---|
AgentChat.tsx |
Container wiring chat state to controlled ChatInterface |
ChatInterface.tsx |
Stateless controlled UI; renders messages, inp |
Установить writing-typescript-code в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл writing-typescript-code?
Provides TypeScript and React coding standards for this repository. Use when writing or modifying TypeScript code, creating React components, implementing MSAL authentication, or working with the frontend.
Как установить скилл writing-typescript-code?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл writing-typescript-code запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic