Token导航 LogoToken导航TokenDH.com
前端设计敏感数据github未标认证来源可访问许可证需确认审计通过

writing-typescript-codewriting TypeScript 代码

Agent Skill

用于辅助文档、README、Markdown、说明文和内容稿件的整理与改写。它适合让 Agent 提炼结构、补齐章节、统一术语、检查链接或把零散材料整理成可读文档。使用时应保留项目已有事实、命令和路径,不要把未确认的信息写成确定结论;涉及对外文案时,还需要控制语气,避免过度营销或夸大能力。

总安装

294

周安装

12

GitHub Stars

86

下载量

95
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:writing-typescript-code(writing TypeScript 代码)
来源仓库:https://github.com/microsoft-foundry/foundry-agent-webapp
仓库路径:skills/writing-typescript-code
安装命令:
npx skills add https://github.com/microsoft-foundry/foundry-agent-webapp --skill writing-typescript-code
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/microsoft-foundry/foundry-agent-webapp --skill writing-typescript-code

简介

用于辅助文档、README、Markdown 和内容稿件的整理与改写。

  • 适合提炼结构、补齐章节、统一术语或检查链接,提升内容可读性。
  • 使用时应保留项目已有事实和路径,避免写成确定结论;对外文案需注意语气控制。
  • 安装命令:npx skills add https://github.com/microsoft-foundry/foundry-agent-webapp --skill writing-typescript-code。
  • 支持 Codex、Claude、Cursor、Gemini CLI,通过 GitHub 仓库安装。

SKILL.md

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:

  1. Save the file - Vite instantly updates the browser (no refresh needed)
  2. Check the terminal - Look for HMR updates in the "Frontend: React Vite" terminal
  3. State is preserved - React state persists through most edits

VS Code Tasks (use Run Task command or check terminal panel):

  • Frontend: React Vite - Runs npm run dev with 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 ID
  • VITE_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 any type
  • ❌ Storing tokens in component state
  • ❌ Running npm install outside frontend/ (misses .npmrc config)
  • ❌ Missing memoization in custom hooks (causes infinite re-renders)
  • ❌ Returning new objects from hooks without useMemo

Project-Specific: Architecture

ConcernImplementation
State ManagementCentralized Context + useReducer (AppContext) with discriminated action union
AuthenticationMSAL redirect flow; silent token refresh; useAuth hook
Chat StreamingSSE in ChatService with abort controllers for cancellation
AccessibilityLive region (aria-live), aria labels, focus management
LoggingDev-only diff-based logger

Project-Specific: Key Components

ComponentPurpose
AgentChat.tsxContainer wiring chat state to controlled ChatInterface
ChatInterface.tsxStateless controlled UI; renders messages, input, errors, BuiltWithBadge
chat/AssistantMessage.tsxMemoized assistant message with streaming + citation footnotes
chat/UserMessage.tsxMemoized user message with image thumbnail previews
chat/ChatInput.tsxFile uploads, character counter, cancel streaming button
chat/CitationMarker.tsxInline superscript citation badge with tooltip + click handler
core/Markdown.tsxRenders markdown with inline citation markers via ContentWithCitations
core/BuiltWithBadge.tsx"Built with Microsoft Foundry" link badge (centered under input)

Project-Specific: Citation System

Parser: frontend/src/utils/citationParser.ts

Handles Azure AI Agent citation formats:

  • Assistants/Responses API: 【4:0†source】, 【13†myfile.pdf】
  • Azure OpenAI On Your Data: [doc1], [doc2]

Flow:

  1. parseContentWithCitations() replaces placeholders with [N] markers
  2. Markdown.tsx renders CitationMarker components for each [N]
  3. Clicking inline marker scrolls to footnote (with highlight animation) or opens URL
  4. AssistantMessage.tsx renders footnote list with icons by type (URI/file/document)

Key Types (frontend/src/types/chat.ts):

  • IAnnotation - Citation metadata (type, label, url, fileId, quote, textToReplace)
  • IndexedCitation - Parsed citation with display index

Project-Specific: File Upload Validation

Limits: 5MB per file, max 5 files total

See: frontend/src/utils/fileAttachments.ts for validateImageFile() and validateFileCount()

Project-Specific: ChatService

File: frontend/src/services/chatService.ts

Key patterns:

  • Class-based service with Dispatch<AppAction> for state updates
  • AbortController for stream cancellation (cancelStream())
  • retryWithBackoff() for resilient API calls (3 retries, 1s initial delay)
  • SSE parsing via parseSseLine() and splitSseBuffer() utilities
  • Duplicate chunk suppression to prevent UI flicker

Methods:

MethodPurpose
sendMessage()Orchestrates auth, file conversion, streaming
cancelStream()Aborts active stream, dispatches CHAT_CANCEL_STREAM
clearChat()Resets conversation state
clearError()Clears error without affecting chat

Project-Specific: Adding Features

  1. Extend state: Add discriminated action to AppAction union in frontend/src/types/appState.ts
  2. Handle in reducer: Update frontend/src/reducers/appReducer.ts (keep pure, no side effects)
  3. Create service method: Add to ChatService if network interaction needed
  4. Wire container: Update AgentChat.tsx to dispatch actions
  5. Update UI: Pass callbacks to controlled component

Project-Specific: Accessibility Checklist

  • ✅ Live region announces latest assistant message
  • aria-busy attribute on messages container during streaming
  • ✅ Buttons have aria-label when icon-only
  • ✅ Focus returns to input after sending
  • ✅ Character counter linked via aria-describedby

Related Skills

  • implementing-chat-streaming - SSE streaming patterns and frontend state flow
  • troubleshooting-authentication - MSAL popup issues and token debugging
  • testing-with-playwright - Browser testing and accessibility validation

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.26%
按下载量换算36

Claude

28.58%
按下载量换算27

Cursor

19.43%
按下载量换算18

Gemini CLI

9.79%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills