# How to teach Codex your knowledge

Teach Codex [durable instructions](https://www.knowman.io/guides/persistent-memory-for-ai-agents) with `AGENTS.md`, global guidance in `~/.codex/AGENTS.md`, and [project rules](https://www.knowman.io/guides/knowledge-base-for-ai-agents) in the repository. Codex reads these files before doing work and combines global guidance with project-specific instructions ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). Keep [saved articles](https://www.knowman.io/guides/how-to-save-articles) and other KnowMan items separate until Codex support for connecting KnowMan tools is confirmed.

## Start with global instructions

Create `~/.codex/AGENTS.md` for reusable preferences that apply across repositories ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). Codex reads `AGENTS.override.md` if it exists at global scope, otherwise it reads `AGENTS.md`, and it uses only the first non-empty global [instruction file](https://www.knowman.io/guides/give-your-ai-context) ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)).

## Add project rules

Add `AGENTS.md` at the repository root for repository norms ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). At project scope, Codex searches from the project root down to the current working directory, checking `AGENTS.override.md`, then `AGENTS.md`, then configured fallback names, with at most one instruction file per directory ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)).

## Use overrides near the work

Put specialized overrides close to the relevant work because Codex stops its search at the current directory ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). Files closer to the current directory appear later in the combined prompt and override earlier guidance ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). If a repository already uses a name such as `TEAM_GUIDE.md`, add it to `project_doc_fallback_filenames` ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)).

## Keep instructions within Codex limits

Codex skips empty instruction files and stops adding files when the combined size reaches `project_doc_max_bytes`, which defaults to 32 KiB ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). Codex builds its instruction chain once per run, usually once per launched TUI session, so restart it in the target directory when guidance changes ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)).

## Check what Codex loaded

Ask Codex to summarize its current instructions, for example with `codex --ask-for-approval never "Summarize the current instructions."` ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). To audit loaded files, enable a plaintext TUI log with `codex -c log_dir=./.codex-log` and inspect `./.codex-log/codex-tui.log` ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)).

## Separate instructions from knowledge

Use `AGENTS.md` for durable instructions that Codex should apply while working. KnowMan saves articles and links, reads and tags them, [answers questions](https://www.knowman.io/guides/ai-knowledge-base) with citations, and keeps claims, decisions, and playbooks ([KnowMan overview](https://www.knowman.io/guides/personal-knowledge-base)). A confirmed Codex connection is needed before treating saved KnowMan items as context for Codex.

## Keep the knowledge library local

KnowMan runs locally with npx -y @knowman/mcp and as a hosted server at https://api.knowman.io/mcp with OAuth sign-in or an API key ([KnowMan MCP guide](https://www.knowman.io/guides/mcp-server-knowledge-base)). KnowMan documents MCP setups for Claude Desktop, Claude Code, and Cursor, but not Codex.

## Plan a Codex connection carefully

KnowMan's MCP package is `@knowman/mcp`. It requires Node 22 or newer and uses a `KNOWMAN_API_KEY` or a saved CLI sign-in credential. Before attempting a [Codex setup](https://www.knowman.io/integrations/codex), confirm that the client supports local stdio MCP servers and that its configuration supports the `mcpServers` format.

## Connect Codex to the hosted KnowMan server

In clients that support remote MCP servers, you add the server URL https://api.knowman.io/mcp and sign in with OAuth. The client opens the KnowMan consent page, where you approve the knowman.read scope for search, read, and ask tools and knowman.write for saving links. Access tokens last one hour and refresh automatically.

The alternative is an API key, created in KnowMan settings and sent as an Authorization: Bearer header to https://api.knowman.io/mcp. A key cannot create other keys, and you disconnect an app by deleting its OAuth entry in your KnowMan API-keys list.

Once connected, the same six tools are available as with the [local server](https://www.knowman.io/guides/what-is-an-mcp-server): kb_search, kb_ask, kb_get_item, kb_save, kb_recent, and the read-only kb_memories. You can then ask Codex to search your KnowMan for a topic or save a URL.

## Questions

### Where should I put instructions for Codex?

Put reusable preferences in `~/.codex/AGENTS.md` and repository rules in `AGENTS.md` at the project root ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). Codex combines global guidance with project-specific instructions ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)).

### How do I give Codex different rules for one project?

Add `AGENTS.md` in the repository and use `AGENTS.override.md` for an override ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). Put specialized overrides close to the relevant work because Codex stops searching at the current directory ([Codex documentation](https://learn.chatgpt.com/docs/agent-configuration/agents-md)).

### Can Codex search articles saved in KnowMan?

That workflow is not confirmed. KnowMan's MCP tools can search saved items and read one item, but Codex support for connecting and using the local server is not documented.

### Can Codex save new articles to KnowMan?

That workflow is not confirmed. KnowMan provides `kb_save` for saving a URL, but Codex support for connecting and using the local server is not documented.

## Related guides

- [What Is a Knowledge Base for AI Agents?](https://www.knowman.io/guides/knowledge-base-for-ai-agents)

- [Connect your knowledge base through KnowMan's MCP server](https://www.knowman.io/guides/mcp-server-knowledge-base)

- [How to Give Your AI Context from What You Read](https://www.knowman.io/guides/give-your-ai-context)

- [What is a personal knowledge base, and how do you build one?](https://www.knowman.io/guides/personal-knowledge-base)

## More in this topic

- [How to teach Cursor your knowledge](https://www.knowman.io/guides/teach-cursor-your-knowledge)
- [How to teach Gemini CLI your knowledge](https://www.knowman.io/guides/teach-gemini-cli-your-knowledge)
- [How to teach Devin CLI your knowledge](https://www.knowman.io/guides/teach-devin-cli-your-knowledge)

## More for Codex

- [KnowMan MCP server for Codex](https://www.knowman.io/integrations/codex)
- [How to give Codex better memory](https://www.knowman.io/guides/codex-memory)

## Build your personal knowledge library

Try KnowMan Pro for 14 days with no credit card. [Create your account](https://app.knowman.io/signup)

[Start free](https://app.knowman.io/signup)

Every new account starts with 14 days of Pro. No credit card.

Source: https://www.knowman.io/guides/teach-codex-your-knowledge
