> For the complete documentation index, see [llms.txt](https://scope.onepub.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scope.onepub.dev/fundamentals/debugging.md).

# Debugging

The Scope package is generally very easy to use as it works as expected in almost all cases.

### debugName

For the times when you are having problems, you can pass a `debugName` to each `Scope` and `ScopeKey`.

{% hint style="success" %}
If you are having problems debugging a Scope issue, start by adding a unique debugName to every Scope and ScopeKey.
{% endhint %}

We recommend that you pass the `debugName` to all your Scope's and ScopeKeys. It will make debugging problems much easier if you get into the habit.

```dart
final key = ScopeKey<int>('debug key name');

Scope('debug scope name')
..value(key, 1);
```

When running in the debugger the `debugName` will be displayed.

You can also print out the `debugName` for a `ScopeKey` or `Scope` by calling their `toString()` method.

### Nested Scopes

Probably the most complex situation is when you have nested Scopes.  Check the call stack for multiple Scope instances.

When you call `use` within a Nested Scope it will search 'up' the call stack looking for the first Scope. If the key is found in that Scope then that value is returned. If the key isn't found we keep searching up the stack for additional Scopes.

The methods `withinScope` and `hasScopeKey` can also help debugging problems when calling `use`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://scope.onepub.dev/fundamentals/debugging.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
