{"schema_version":"1.0","publisher":"Primitive SDKs","canonical_url":"https://test.abhinandan.one/cli-overview/cli-memories-and-chat","markdown_url":"https://test.abhinandan.one/cli-overview/cli-memories-and-chat.md","article":{"id":"c6155139-db7b-400f-a891-64de942b22b8","article_slug":"cli-memories-and-chat","parent_article_slug":"cli-overview","parent_article_title":"What is the Primitive CLI?","kind":"guide","published_at":"2026-08-11T18:54:56.201423+00:00","keywords":["primitive memories set","primitive memories get","primitive memories search","primitive memories delete","primitive chat","function-scoped memories"],"meta_description":"The primitive memories command group reads and writes durable JSON key-value records, and primitive chat opens an interactive REPL against your account.","og_image_url":null,"source_file_paths":[],"recording_id":null,"replayable":false,"task_name":"Memories and Chat Commands","category":"CLI","summary":null,"description":"Store, fetch, and search durable JSON records from the terminal with primitive memories, and use the interactive primitive chat REPL for testing conversational flows against your account.","content_kind":"repo_page","content_markdown":"The `primitive memories` command group reads and writes [Primitive Memories](node-sdk-api-client), the durable JSON key-value record store, directly from the terminal. `primitive chat` opens an interactive REPL for testing conversational flows against your account without writing a script first.\n\nUse `memories` when you're debugging what a function or agent has stored, seeding state before a test run, or clearing stale keys. Use `chat` when you want a quick interactive session without standing up a client.\n\nValues must be valid JSON, and `memories search` matches key prefixes only, not free text.\n\n## Prerequisites\n\n- The CLI installed and authenticated. See [Authentication: login, signup, logout, whoami](cli-authentication).\n- A Primitive API key, either from `primitive login` credentials or `PRIMITIVE_API_KEY`.\n\n## Store and retrieve memories\n\nUse `primitive memories set`, `get`, `search`, and `delete` to manage durable JSON records from the terminal. Memories default to org scope. Pass `--function <function-id>` to read or write the same key under a function's scope instead; the value must be the function's id UUID, not its name.\n\n<Steps>\n\n<Step title=\"Set a memory value\">\n\nValues must be valid JSON. Quote plain strings as JSON strings.\n\n```bash\nprimitive memories set thread:latest '{\"email_id\":\"em_123\"}'\nprimitive memories set greeting '\"hello\"'\n```\n\nValues must be valid JSON, so a plain string has to be quoted as a JSON string: use `'\"hello\"'`, not `hello`.\n\n</Step>\n\n<Step title=\"Get a memory value\">\n\n```bash\nprimitive memories get thread:latest\n```\n\n</Step>\n\n<Step title=\"Search memories by key prefix\">\n\n`memories search` is key-prefix search, not free-text or semantic search. For free-text mail search use `primitive search` or `primitive semantic-search` instead.\n\n```bash\nprimitive memories search thread:\n```\n\nPass `--metadata-only` to list matching keys without fetching each value, useful for a quick inventory scan:\n\n```bash\nprimitive memories search thread: --metadata-only\n```\n\n</Step>\n\n<Step title=\"Delete a memory\">\n\n```bash\nprimitive memories delete thread:latest\n```\n\n</Step>\n\n</Steps>\n\n### Function-scoped memories\n\nPass `--function <function-id>` on any of the four subcommands to read or write the same key under a specific function's scope instead of the org's:\n\n```bash\nprimitive memories set state '{\"step\":2}' --function <function-id>\nprimitive memories get state --function <function-id>\n```\n\n<Tip>\n\nThe `--function` value is the function's id UUID, not its name. If you only have the name, look the id up with `primitive functions list`.\n\n</Tip>\n\n<Warning>\n\n`primitive memories delete` is permanent. There is no undo and no trash/recovery period for a deleted key.\n\n</Warning>\n\n## Interactive chat REPL\n\n`primitive chat` opens an interactive REPL against your account, so you can exercise a conversational flow without writing a throwaway script.\n\n```bash\nprimitive chat\n```\n\nInside the REPL, reply to the active thread the same way the SDK's `client.reply` would, including attachments:\n\n```bash\nprimitive chat reply \"See attached\" --attachment ./report.pdf\n```\n\n<Note>\n\n`primitive logout --force` clears local CLI credentials, pending email-code auth state, and stale credential locks without contacting Primitive. Reach for it when an interrupted auth command leaves the CLI reporting that another credential operation is already in progress. See [Authentication: login, signup, logout, whoami](cli-authentication).\n\n</Note>\n\n## Next steps\n\n<CardGroup cols={2}>\n\n<Card title=\"Generated API Client and Primitive Memories\" href=\"node-sdk-api-client\">\n\nSee the Node SDK's client.memories API that the CLI wraps, including org vs. function scope semantics.\n\n</Card>\n\n<Card title=\"Direct API Access and Generic Commands\" href=\"cli-generic-api-access\">\n\nCall the raw memories operations directly through the CLI's generic api-command shortcut.\n\n</Card>\n\n<Card title=\"Primitive Functions: Deploy, Route, and Manage\" href=\"cli-functions\">\n\nDeploy the functions whose function-id you'll pass to --function when scoping memories.\n\n</Card>\n\n<Card title=\"Sending, Replying, and Searching Email from the CLI\" href=\"cli-email-commands\">\n\nUse primitive search or semantic-search for free-text mail search instead of memories search.\n\n</Card>\n\n</CardGroup>","canonical_base_url":"https://test.abhinandan.one","seo_indexing_enabled":true,"last_modified":"2026-08-21T18:22:43.359885+00:00","video_url":null,"voiceover_url":null,"tools_used":[],"demonstrated_by":[],"steps":[],"related_links":[],"intro":null,"prerequisites":[],"verification":[],"troubleshooting":[],"suggest_edit_url":null,"raise_issue_url":"https://github.com/abhi-browzer/primitive-sdks/issues/new?title=Docs+feedback%3A+Memories+and+Chat+Commands&body=Page%3A+https%3A%2F%2Ftest.abhinandan.one%2Fcli-memories-and-chat","page_feedback_enabled":true,"verified_ref":null,"verified_at":"2026-08-11T18:38:45.205849+00:00"}}