AWS Security ChangesHomeSearch

AWS amazonq documentation change

Service: amazonq · 2025-08-13 · Documentation low

File: amazonq/latest/qdeveloper-ug/command-line-context.md

Summary

Restructured context management documentation to differentiate between persistent agent resources and temporary session context, added configuration examples for agent resource files, removed global context references, and emphasized persistent configuration through agent files

Security assessment

The changes focus on improving context management structure without addressing security vulnerabilities. While security.md is mentioned as a sample file, this is part of normal configuration examples rather than introducing new security features or patching vulnerabilities. The modifications are organizational and clarify persistence mechanisms rather than addressing security risks.

Diff

diff --git a/amazonq/latest/qdeveloper-ug/command-line-context.md b/amazonq/latest/qdeveloper-ug/command-line-context.md
index f0dc59a6d..90843242b 100644
--- a//amazonq/latest/qdeveloper-ug/command-line-context.md
+++ b//amazonq/latest/qdeveloper-ug/command-line-context.md
@@ -13 +13 @@ Context files contain information you want Amazon Q to consider during your conv
-### Adding context
+There are two ways to configure context:
@@ -15 +15 @@ Context files contain information you want Amazon Q to consider during your conv
-You can add files or directories to your context using the `/context add` command:
+  * **Agent resources** (recommended): Persistent context defined in your agent configuration file
@@ -16,0 +17 @@ You can add files or directories to your context using the `/context add` comman
+  * **Session context** : Temporary context added during a chat session using `/context` commands
@@ -18,3 +18,0 @@ You can add files or directories to your context using the `/context add` comman
-    q chat
-    > /context add README.md
-    Added 1 path(s) to profile context.
@@ -22 +20,25 @@ You can add files or directories to your context using the `/context add` comman
-To add a file to the global context (available across all profiles), use the `--global` flag:
+
+
+### Configuring persistent context with agent resources
+
+The recommended way to configure context is through the `resources` field in your agent configuration file. This creates persistent context that is available every time you use the agent.
+
+Add file paths or glob patterns to the `resources` array in your agent config:
+    
+    
+    {
+      "name": "my-agent",
+      "description": "My development agent",
+      "resources": [
+        "file://README.md",
+        "file://.amazonq/rules/**/*.md",
+        "file://docs/**/*.md",
+        "file://src/config.py"
+      ]
+    }
+
+Resources must be prefixed with `file://` to be included as context files. These files will be automatically available in all chat sessions using this agent.
+
+### Adding temporary session context
+
+You can temporarily add files to your current chat session using the `/context add` command. These additions are only available for the current session and will not persist when you start a new chat session.
@@ -26,2 +48,3 @@ To add a file to the global context (available across all profiles), use the `--
-    > /context add --global coding-standards.md
-    Added 1 path(s) to global context.
+    > /context add README.md
+    Added 1 path(s) to context.
+    Note: Context modifications via slash command is temporary.
@@ -34 +57,4 @@ You can also add multiple files at once using glob patterns:
-    Added 3 path(s) to profile context.
+    Added 3 path(s) to context.
+    Note: Context modifications via slash command is temporary.
+
+To make context changes permanent, add the files to your agent's `resources` field instead.
@@ -43,2 +69,4 @@ To view your current context, use the `/context show` command:
-    Global context:
-      /home/user/coding-standards.md
+    👤 Agent (my-agent):
+        README.md (1 match)
+        .amazonq/rules/**/*.md (3 matches)
+        docs/**/*.md (5 matches)
@@ -46,4 +74,2 @@ To view your current context, use the `/context show` command:
-    Profile context (terraform):
-      /home/user/terraform-project/README.md
-      /home/user/terraform-project/docs/architecture.md
-      /home/user/terraform-project/docs/best-practices.md
+    💬 Session (temporary):
+        <none>
@@ -51 +77,6 @@ To view your current context, use the `/context show` command:
-### Removing context
+    5 matched files in use:
+    👤 README.md (~250 tkns)
+    👤 .amazonq/rules/security.md (~180 tkns)
+    👤 .amazonq/rules/coding-standards.md (~320 tkns)
+    👤 docs/architecture.md (~150 tkns)
+    👤 docs/best-practices.md (~200 tkns)
@@ -53 +84 @@ To view your current context, use the `/context show` command:
-To remove files from your context, use the `/context rm` command:
+    Total: ~1100 tokens
@@ -54,0 +86 @@ To remove files from your context, use the `/context rm` command:
+The output shows:
@@ -56,3 +88 @@ To remove files from your context, use the `/context rm` command:
-    q chat
-    > /context rm docs/architecture.md
-    Removed 1 path(s) from profile context.
+  * **👤 Agent** : Persistent context from your agent's `resources` field
@@ -60 +90 @@ To remove files from your context, use the `/context rm` command:
-To remove files from the global context, use the `--global` flag:
+  * **💬 Session** : Temporary context added during the current session
@@ -63,3 +92,0 @@ To remove files from the global context, use the `--global` flag:
-    q chat
-    > /context rm --global coding-standards.md
-    Removed 1 path(s) from global context.
@@ -67 +94,4 @@ To remove files from the global context, use the `--global` flag:
-To clear all files from your context, use the `/context clear` command:
+
+### Removing context
+
+To remove files from your current session context, use the `/context rm` command:
@@ -71,2 +101,3 @@ To clear all files from your context, use the `/context clear` command:
-    > /context clear
-    Cleared all paths from profile context.
+    > /context rm src/temp-file.py
+    Removed 1 path(s) from context.
+    Note: Context modifications via slash command is temporary.
@@ -74 +105 @@ To clear all files from your context, use the `/context clear` command:
-To clear the global context, use the `--global` flag:
+To clear all session context, use the `/context clear` command:
@@ -78,2 +109,5 @@ To clear the global context, use the `--global` flag:
-    > /context clear --global
-    Cleared all paths from global context.
+    > /context clear
+    Cleared context
+    Note: Context modifications via slash command is temporary.
+
+**Note:** You cannot remove agent-defined context using `/context` commands. To permanently remove context, edit your agent's `resources` field.
@@ -83 +117 @@ To clear the global context, use the `--global` flag:
-Here are some common use cases for context profiles:
+Here are some common use cases for context management:
@@ -100 +134 @@ For example, you can create rules that specify:
-Project rules can be added to your context using the `/context add` command:
+The recommended way to include project rules is through your agent configuration:
@@ -103,3 +137,8 @@ Project rules can be added to your context using the `/context add` command:
-    q chat
-    > /context add .amazonq/rules/*.md
-    Added 3 path(s) to profile context.
+    {
+      "name": "my-project-agent",
+      "resources": [
+        "file://.amazonq/rules/**/*.md",
+        "file://README.md",
+        "file://docs/architecture.md"
+      ]
+    }
@@ -107 +146 @@ Project rules can be added to your context using the `/context add` command:
-You can also add project rules to your global context to apply them across all profiles:
+You can also temporarily add project rules to your current session:
@@ -111,2 +150,3 @@ You can also add project rules to your global context to apply them across all p
-    > /context add --global .amazonq/rules/security-standards.md
-    Added 1 path(s) to global context.
+    > /context add .amazonq/rules/*.md
+    Added 3 path(s) to context.
+    Note: Context modifications via slash command is temporary.
@@ -115,0 +156,32 @@ For more information about creating and using project rules, see [Creating proje
+### Migrating from session context to agent resources
+
+If you find yourself repeatedly adding the same context files using `/context add` commands, consider moving them to your agent's `resources` field for persistence:
+
+  1. Note the files you frequently add with `/context add`
+
+  2. Edit your agent configuration file
+
+  3. Add the file paths to the `resources` array with `file://` prefix
+
+  4. Save the agent configuration
+
+
+
+
+Example migration:
+    
+    
+    # Instead of running these commands every session:
+    > /context add README.md
+    > /context add docs/*.md
+    > /context add .amazonq/rules/*.md
+    
+    # Add them to your agent config once:
+    {
+      "resources": [
+        "file://README.md",
+        "file://docs/**/*.md", 
+        "file://.amazonq/rules/**/*.md"
+      ]
+    }
+