Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Todo-Verfolgung bietet eine strukturierte Möglichkeit, Aufgaben zu verwalten und den Fortschritt den Benutzern anzuzeigen. Das Claude Agent SDK enthält integrierte Todo-Funktionalität, die dabei hilft, komplexe Arbeitsabläufe zu organisieren und Benutzer über den Aufgabenfortschritt zu informieren.
Todos folgen einem vorhersagbaren Lebenszyklus:
pending, wenn Aufgaben identifiziert werdenin_progress, wenn die Arbeit beginntDas SDK erstellt automatisch Todos für:
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Optimiere die Leistung meiner React-App und verfolge den Fortschritt mit Todos",
options: { maxTurns: 15 }
})) {
// Todo-Updates werden im Nachrichtenstrom widergespiegelt
if (message.type === "tool_use" && message.name === "TodoWrite") {
const todos = message.input.todos;
console.log("Todo-Status-Update:");
todos.forEach((todo, index) => {
const status = todo.status === "completed" ? "✅" :
todo.status === "in_progress" ? "🔧" : "❌";
console.log(`${index + 1}. ${status} ${todo.content}`);
});
}
}import { query } from "@anthropic-ai/claude-agent-sdk";
class TodoTracker {
private todos: any[] = [];
displayProgress() {
if (this.todos.length === 0) return;
const completed = this.todos.filter(t => t.status === "completed").length;
const inProgress = this.todos.filter(t => t.status === "in_progress").length;
const total = this.todos.length;
console.log(`\nFortschritt: ${completed}/${total} abgeschlossen`);
console.log(`Arbeitet derzeit an: ${inProgress} Aufgabe(n)\n`);
this.todos.forEach((todo, index) => {
const icon = todo.status === "completed" ? "✅" :
todo.status === "in_progress" ? "🔧" : "❌";
const text = todo.status === "in_progress" ? todo.activeForm : todo.content;
console.log(`${index + 1}. ${icon} ${text}`);
});
}
async trackQuery(prompt: string) {
for await (const message of query({
prompt,
options: { maxTurns: 20 }
})) {
if (message.type === "tool_use" && message.name === "TodoWrite") {
this.todos = message.input.todos;
this.displayProgress();
}
}
}
}
// Verwendung
const tracker = new TodoTracker();
await tracker.trackQuery("Erstelle ein vollständiges Authentifizierungssystem mit Todos");