Skip to content

8. 最佳实践

8.1 记忆组织

DO ✅:

markdown
## Tech Stack
- React 18 + TypeScript
- Vite 5
- Zustand for state

## Conventions
- Use functional components
- Prefer named exports
- TypeScript strict mode

## Links
- [Detailed Patterns](./patterns.md)

DON'T ❌:

markdown
## Everything About The Project

We use React and TypeScript. The project was started in 2025.
We have many components in the src/components folder.
The main file is App.tsx which renders the root component.
We use Vite for building. The vite.config.ts file has...
[继续 500 行...]

8.2 压缩策略

typescript
// 好的压缩:保留关键信息
const goodCompression = `
Ran: npm test
Result: 15 tests passed, 2 failed
Failed tests:
  - UserService.test.ts:45 - Expected 200, got 404
  - AuthService.test.ts:23 - Token expired
`;

// 坏的压缩:丢失重要细节
const badCompression = `
Ran tests. Some failed.
`;

8.3 检索优化

typescript
// 好的查询:具体明确
await memory.recall("How do we handle authentication errors?");

// 坏的查询:过于宽泛
await memory.recall("errors");

前端面试知识库