add-route-context

为Flutter页面添加路由上下文记录功能,支持日期等参数的AI上下文识别。当需要让AI助手通过"询问当前上下文"功能获取页面状态(如日期、ID等参数)时使用。适用场景:(1) 日期驱动的页面(日记、活动、日历等),(2) ID驱动的页面(用户详情、订单详情等),(3) 任何需要AI理解当前页面参数的场景

16 stars

Best use case

add-route-context is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

为Flutter页面添加路由上下文记录功能,支持日期等参数的AI上下文识别。当需要让AI助手通过"询问当前上下文"功能获取页面状态(如日期、ID等参数)时使用。适用场景:(1) 日期驱动的页面(日记、活动、日历等),(2) ID驱动的页面(用户详情、订单详情等),(3) 任何需要AI理解当前页面参数的场景

Teams using add-route-context should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/add-route-context/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/data-ai/add-route-context/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/add-route-context/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How add-route-context Compares

Feature / Agentadd-route-contextStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

为Flutter页面添加路由上下文记录功能,支持日期等参数的AI上下文识别。当需要让AI助手通过"询问当前上下文"功能获取页面状态(如日期、ID等参数)时使用。适用场景:(1) 日期驱动的页面(日记、活动、日历等),(2) ID驱动的页面(用户详情、订单详情等),(3) 任何需要AI理解当前页面参数的场景

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Add Route Context

为Flutter页面添加路由上下文记录,使AI助手能理解用户当前查看的页面参数。

## Workflow

### 1. Analyze Target File

Read the target file and identify:

- State class name
- Parameter variable (e.g., `_selectedDate`, `_userId`)
- Parameter change method (e.g., `_onDateChanged`)
- Initialization method (e.g., `initState`, `_initializeService`)

### 2. Add RouteHistoryManager Import

```dart
import 'package:Memento/core/route/route_history_manager.dart';
```

### 3. Create Update Method

**For DateTime parameter:**

```dart
/// 更新路由上下文,使"询问当前上下文"功能能获取到当前日期
void _updateRouteContext(DateTime date) {
  final dateStr = '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
  RouteHistoryManager.updateCurrentContext(
    pageId: "/route_name",
    title: '页面标题 - $dateStr',
    params: {'date': dateStr},
  );
}
```

**For custom parameter:**

```dart
/// 更新路由上下文
void _updateRouteContext(String paramValue) {
  RouteHistoryManager.updateCurrentContext(
    pageId: "/route_name",
    title: '页面标题 - $paramValue',
    params: {'paramName': paramValue},
  );
}
```

### 4. Call in Initialization

Add call at end of initialization method:

```dart
Future<void> _initializeService() async {
  // ... existing code ...

  // 初始化时设置路由上下文
  _updateRouteContext(_initialParam);
}
```

### 5. Call on Parameter Change

Add call in parameter change handler:

```dart
void _onParamChanged(ParamType newParam) {
  if (newParam == _currentParam) return;

  setState(() {
    _currentParam = newParam;
  });
  // ... existing code ...

  // 更新路由上下文
  _updateRouteContext(newParam);
}
```

### 6. Update Route Parser

Add route template to `lib/core/action/built_in/ask_context_action/route_parser.dart`:

```dart
static const Map<String, String> _routeTemplates = {
  // ... existing routes ...

  // 插件名称
  '/route_name': '用户正在查看 {paramName} 的XXX',
};
```

**DateTime parameter example:**

```dart
'/activity_timeline': '用户正在查看 {date} 的活动时间轴',
```

**Custom parameter example:**

```dart
'/user_profile': '用户正在查看 {userId} 的用户资料',
```

## Detection Patterns

### DateTime Variables

Look for variables matching:
- Names: `_selectedDate`, `_currentDate`, `_focusedDay`, `date`
- Type: `DateTime`

Look for methods matching:
- Names: `_onDateChanged`, `_onDayChanged`, `_selectDate`
- Parameter type: `DateTime`

### Custom Parameters

Look for variables matching the `--param` argument name.

## Result

After execution:

**在页面加载时:**
- AI上下文:`用户正在查看 2025-12-22 的活动时间轴`

**在参数变化时:**
- AI上下文自动更新:`用户正在查看 2025-12-21 的活动时间轴`

## Notes

- Extract update logic to separate method to avoid duplication
- Use Chinese comments matching existing codebase style
- Format dates as `YYYY-MM-DD` for consistency
- Route parser uses `RegExp(r'\{(\w+)\}')` for placeholder replacement
- Verify with `flutter analyze` after changes

Related Skills

extracting-ai-context

16
from diegosouzapw/awesome-omni-skill

Extracts and manages AI context (skills, AGENTS.md) from workflow-kotlin library JARs. Use when setting up AI tooling for a workflow-kotlin project, updating skills after a library version change, or configuring agent-specific directories.

create-agent-with-sanity-context

16
from diegosouzapw/awesome-omni-skill

Build AI agents with structured access to Sanity content via Context MCP. Covers Studio setup, agent implementation, and advanced patterns like client-side tools and custom rendering.

context-optimizer

16
from diegosouzapw/awesome-omni-skill

Analyzes Copilot Chat debug logs, agent definitions, skills, and instruction files to audit context window utilization. Provides log parsing, turn-cost profiling, redundancy detection, hand-off gap analysis, and optimization recommendations. Use when optimizing agent context efficiency, identifying where to add subagent hand-offs, or reducing token waste across agent systems.

context-fundamentals

16
from diegosouzapw/awesome-omni-skill

Understand the components, mechanics, and constraints of context in agent systems. Use when designing agent architectures, debugging context-related failures, or optimizing context usage.

context-engineering

16
from diegosouzapw/awesome-omni-skill

Use when designing agent system prompts, optimizing RAG retrieval, or when context is too expensive or slow. Reduces tokens while maintaining quality through strategic positioning and attention-aware design.

context-degradation

16
from diegosouzapw/awesome-omni-skill

Recognize patterns of context failure: lost-in-middle, poisoning, distraction, and clash

context-assembler

16
from diegosouzapw/awesome-omni-skill

Assembles relevant context for agent spawns with prioritized ranking. Ranks packages by relevance, enforces token budgets with graduated zones, captures error patterns for learning, and supports configurable per-agent retrieval limits.

Codebase context

16
from diegosouzapw/awesome-omni-skill

Create a lightweight codebase_context.md that anchors the idea in the existing repo (modules, constraints, extension points). Generic framework prompt.

agent-context-system

16
from diegosouzapw/awesome-omni-skill

A persistent local-only memory system for AI coding agents. Two files, one idea — AGENTS.md (committed, shared) + .agents.local.md (gitignored, personal). Agents read both at session start, update the scratchpad at session end, and promote stable patterns over time. Works across Claude Code, Cursor, Copilot, Windsurf. Subagent-ready. No plugins, no infrastructure, no background processes.

localsetup-context

16
from diegosouzapw/awesome-omni-skill

Localsetup v2 framework context - overview, invariants, and skills index. Load first when working in a repo that uses Localsetup v2. Use when starting work in this repo or when user asks about framework rules.

context7-skills

16
from diegosouzapw/awesome-omni-skill

Use when a user asks to search, install, list, or remove skills with the Context7 ctx7 skills CLI (including npx ctx7) and needs correct subcommands or client flags.

cli-context

16
from diegosouzapw/awesome-omni-skill

Explains the CLI app architecture and capabilities. Use when working on CLI features, debugging CLI issues, or needing to understand the TTS pipeline, emotion annotation, or command flags.