{"id":34979227,"url":"https://github.com/cognizonline/claude-memory-hooks","last_synced_at":"2026-04-27T19:33:47.609Z","repository":{"id":329566166,"uuid":"1119964668","full_name":"cognizonline/claude-memory-hooks","owner":"cognizonline","description":"Claude Code integration for Cogniz Memory Platform - Auto-save code, load context, and search memories","archived":false,"fork":false,"pushed_at":"2025-12-20T11:21:31.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-22T16:06:34.607Z","etag":null,"topics":["ai-assistant","claude-ai","claude-code","cogniz","developer-tools","hooks","memory-platform","productivity"],"latest_commit_sha":null,"homepage":"https://cogniz.online","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cognizonline.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-20T07:39:51.000Z","updated_at":"2025-12-20T12:09:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cognizonline/claude-memory-hooks","commit_stats":null,"previous_names":["cognizonline/claude-memory-hooks"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/cognizonline/claude-memory-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cognizonline%2Fclaude-memory-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cognizonline%2Fclaude-memory-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cognizonline%2Fclaude-memory-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cognizonline%2Fclaude-memory-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cognizonline","download_url":"https://codeload.github.com/cognizonline/claude-memory-hooks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cognizonline%2Fclaude-memory-hooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32352397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T17:12:42.749Z","status":"ssl_error","status_checked_at":"2026-04-27T17:12:41.658Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-assistant","claude-ai","claude-code","cogniz","developer-tools","hooks","memory-platform","productivity"],"created_at":"2025-12-27T00:51:46.417Z","updated_at":"2026-04-27T19:33:47.603Z","avatar_url":"https://github.com/cognizonline.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cogniz Claude Code Integration\n\n**Connect Claude Code to your persistent memory layer with automatic context management.**\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![Claude Code](https://img.shields.io/badge/Claude_Code-Compatible-purple.svg)](https://claude.ai/code)\n\nAutomatically connect your Claude Code workflow to [Cogniz Memory Platform](https://cogniz.online), enabling persistent memory across coding sessions.\n\n\u003e **Research Preview**: These hooks are currently in research preview and actively being upgraded. A free tier is available on [Cogniz Memory Platform](https://cogniz.online).\n\n## Features\n\n- **Auto-Save**: Important code changes saved automatically to your memory platform\n- **Context Loading**: Claude remembers your previous work when you start new sessions\n- **Smart Search**: Find relevant memories when asking questions\n- **Project Organization**: Memories automatically organized by your code projects\n- **Auto-Documentation**: Your work history automatically recorded and searchable\n\n## Quick Start\n\n### Prerequisites\n\n- [Claude Code](https://claude.ai/code) installed\n- [Cogniz Memory Platform](https://cogniz.online) account (free tier available)\n- Python 3.8+ or Bash shell\n- `jq` (for shell scripts): `brew install jq` or `apt-get install jq`\n\n### Installation\n\n**Step 1: Clone into your project**\n\n```bash\ncd your-project-directory\ngit clone https://github.com/cognizonline/cogniz-claude-code.git .claude\n```\n\n**Step 2: Get your Cogniz API key**\n\nVisit [https://cogniz.online/dashboard](https://cogniz.online/dashboard) → API Keys → Create New Key\n\n**Step 3: Configure your API key**\n\nEdit `.claude/project-config.json`:\n\n```json\n{\n  \"cogniz\": {\n    \"api_key\": \"YOUR_API_KEY_HERE\",\n    \"api_url\": \"https://cogniz.online/wp-json/memory/v1\",\n    \"default_project\": \"my-project\"\n  }\n}\n```\n\nOr use environment variables:\n\n```bash\necho \"COGNIZ_API_KEY=your_key_here\" \u003e .claude/.env\n```\n\n**Step 4: Make hooks executable (Mac/Linux only)**\n\n```bash\nchmod +x .claude/hooks/*.sh\n```\n\n**Step 5: Test the integration**\n\n```bash\ncurl -X GET \"https://cogniz.online/wp-json/memory/v1/user-stats\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n```\n\nExpected response: `{\"success\": true, ...}`\n\n**Step 6: Start coding**\n\nOpen Claude Code in your project. The integration will automatically:\n- Load recent memories from your previous sessions\n- Detect which project you're working on\n- Save important code changes as you work\n\n## How It Works\n\n### Automatic Project Detection\n\nYour code repositories are automatically mapped to Cogniz projects based on directory structure:\n\n```\nyour-workspace/\n├── my-app/              → Cogniz Project: \"my-app\"\n├── backend-api/         → Cogniz Project: \"backend-api\"\n└── frontend/            → Cogniz Project: \"frontend\"\n```\n\n### Three Smart Hooks\n\nThe integration uses three Claude Code hooks to manage memory:\n\n**1. SessionStart Hook**\n- Runs when you start a new Claude Code session\n- Loads recent memories from the current project\n- Provides context about your previous work\n\n**2. PostToolUse Hook**\n- Runs after Edit or Write operations\n- Automatically saves significant code changes\n- Filters by file type and content size\n\n**3. UserPromptSubmit Hook**\n- Runs before processing your messages\n- Searches memories when you ask questions\n- Injects relevant context from your history\n\n## Configuration\n\n### Basic Configuration\n\n```json\n{\n  \"cogniz\": {\n    \"api_key\": \"YOUR_API_KEY\",\n    \"api_url\": \"https://cogniz.online/wp-json/memory/v1\",\n    \"default_project\": \"my-project\"\n  },\n  \"projects\": {\n    \"auto-detect\": true,\n    \"mappings\": [\n      {\n        \"directory_pattern\": \"**/my-app/**\",\n        \"cogniz_project_id\": \"my-app\",\n        \"cogniz_project_name\": \"My Application\",\n        \"save_files\": [\"*.js\", \"*.ts\", \"*.py\", \"*.md\"]\n      }\n    ]\n  },\n  \"hooks\": {\n    \"session_start\": {\n      \"enabled\": true,\n      \"load_recent_memories\": true,\n      \"memory_limit\": 5\n    },\n    \"auto_save\": {\n      \"enabled\": true,\n      \"file_types\": [\"*.py\", \"*.js\", \"*.ts\", \"*.md\"],\n      \"exclude_patterns\": [\"**/node_modules/**\", \"**/.git/**\"]\n    },\n    \"search_memories\": {\n      \"enabled\": true,\n      \"trigger_keywords\": [\"remember\", \"previous\", \"earlier\"]\n    }\n  }\n}\n```\n\nSee [docs/CONFIGURATION.md](./docs/CONFIGURATION.md) for complete configuration reference.\n\nSee [examples/](./examples/) for configuration templates for Python, web development, and data science projects.\n\n## Usage Examples\n\n### Starting a New Session\n\nWhen you open Claude Code in a project where you've worked before:\n\n```\nClaude Code (SessionStart):\nCogniz Memory Loaded\n\nProject: Backend API\nRecent work:\n• Added JWT token generation in auth.py\n• Fixed password hashing bug\n• Updated /api/auth/login endpoint\n\n[Session continues with full context]\n```\n\n### Auto-Save Code Changes\n\nWhen you make code changes:\n\n```\nYou: \"Add input validation to login\"\n\nClaude: [Makes changes to auth.py]\n\nPostToolUse:\nSaved to Cogniz (Backend API)\n\nNext session: Claude remembers this change\n```\n\n### Search Your Memories\n\nWhen you ask about previous work:\n\n```\nYou: \"How did we handle password reset before?\"\n\nUserPromptSubmit searches your memory...\n\nClaude:\nFrom Your Cogniz Memory:\nPassword reset: email with token → verify → new password → hash\n```\n\n## Hook Implementation Details\n\n### SessionStart Hook\n\n**File**: `hooks/session-start.py` or `hooks/session-start.sh`\n\n**Trigger**: At the beginning of each Claude Code session\n\n**Process**:\n1. Detects current project from directory path\n2. Fetches recent memories from Cogniz API\n3. Formats and loads context into conversation\n4. Displays project name and memory count\n\n**Configuration**:\n- `enabled`: Enable/disable the hook\n- `load_recent_memories`: Whether to load memories\n- `memory_limit`: Number of memories to load (1-10)\n- `context_length`: Max characters per memory\n\n### PostToolUse Hook\n\n**File**: `hooks/auto-save.py` or `hooks/auto-save.sh`\n\n**Trigger**: After Edit or Write tool usage in Claude Code\n\n**Process**:\n1. Captures the code change content\n2. Checks file type against configured patterns\n3. Validates content length (min/max thresholds)\n4. Excludes files matching exclude patterns\n5. Saves to Cogniz with project association\n\n**Configuration**:\n- `enabled`: Enable/disable auto-save\n- `file_types`: Array of file patterns to save (e.g., `[\"*.py\", \"*.js\"]`)\n- `min_content_length`: Skip small changes (default: 50)\n- `max_content_length`: Truncate large changes (default: 2000)\n- `exclude_patterns`: Patterns to never save (e.g., `[\"**/node_modules/**\"]`)\n\n### UserPromptSubmit Hook\n\n**File**: `hooks/search-memories.py` or `hooks/search-memories.sh`\n\n**Trigger**: Before each user message is processed\n\n**Process**:\n1. Scans user message for trigger keywords\n2. If keywords found, searches Cogniz for relevant memories\n3. Injects search results into context\n4. Claude receives both your message and relevant memories\n\n**Configuration**:\n- `enabled`: Enable/disable memory search\n- `trigger_keywords`: Words that trigger search (e.g., `[\"remember\", \"previous\"]`)\n- `search_limit`: Max search results (1-5)\n- `context_length`: Max characters per result\n\n## Security\n\n### Best Practices\n\n**1. Never commit API keys**\n\nAdd to your project's `.gitignore`:\n```\n.claude/.env\n.claude/project-config.json\n```\n\n**2. Use environment variables**\n\n```bash\nexport COGNIZ_API_KEY=\"your_key\"\n```\n\n**3. Exclude sensitive files from auto-save**\n\n```json\n{\n  \"hooks\": {\n    \"auto_save\": {\n      \"exclude_patterns\": [\n        \"**/.env\",\n        \"**/secrets.json\",\n        \"**/credentials.json\",\n        \"**/private/**\"\n      ]\n    }\n  }\n}\n```\n\n**4. Rotate API keys regularly**\n\nGenerate new API keys every 90 days from your Cogniz dashboard.\n\n## Troubleshooting\n\n### Hooks Not Running\n\nCheck hook file permissions:\n```bash\nls -la .claude/hooks/\n# Should show: -rwxr-xr-x (executable)\n\n# Fix permissions:\nchmod +x .claude/hooks/*.sh\n```\n\n### API Key Errors\n\nTest your API key:\n```bash\ncurl -H \"Authorization: Bearer YOUR_KEY\" \\\n  https://cogniz.online/wp-json/memory/v1/user-stats\n```\n\nExpected response includes `\"success\": true`\n\n### No Memories Loading\n\n1. Verify you have memories in your Cogniz dashboard\n2. Check `load_recent_memories: true` in config\n3. Verify project mapping matches your current directory\n4. Check hook execution in Claude Code logs\n\n### Wrong Project Detected\n\nUpdate project mappings in `project-config.json` with more specific patterns:\n```json\n{\n  \"directory_pattern\": \"**/exact-path/my-app/**\"\n}\n```\n\n## Repository Structure\n\n```\ncogniz-claude-code/\n├── README.md                 # This file\n├── LICENSE                   # MIT License\n├── CONTRIBUTING.md           # Contribution guidelines\n├── CHANGELOG.md              # Version history\n├── hooks.json                # Hook configuration for Claude Code\n├── project-config.json       # Template configuration file\n├── .env.example              # Environment variable template\n├── .gitignore                # Excludes sensitive files\n├── hooks/\n│   ├── session-start.py      # Python: Load context on session start\n│   ├── session-start.sh      # Shell: Load context on session start\n│   ├── auto-save.py          # Python: Auto-save code changes\n│   ├── auto-save.sh          # Shell: Auto-save code changes\n│   ├── search-memories.py    # Python: Search memories on questions\n│   └── search-memories.sh    # Shell: Search memories on questions\n├── examples/\n│   ├── python-project.json   # Configuration for Python projects\n│   ├── web-project.json      # Configuration for web development\n│   └── data-science.json     # Configuration for data science\n└── docs/\n    ├── INSTALLATION.md       # Detailed installation guide\n    └── CONFIGURATION.md      # Complete configuration reference\n```\n\n## Contributing\n\nContributions are welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\n### Documentation\n- **Dashboard**: [https://cogniz.online/dashboard](https://cogniz.online/dashboard)\n- **Full Documentation**: [https://cogniz.online/documentation](https://cogniz.online/documentation)\n- **Installation Guide**: [docs/INSTALLATION.md](./docs/INSTALLATION.md)\n- **Configuration Reference**: [docs/CONFIGURATION.md](./docs/CONFIGURATION.md)\n\n### Community\n- **GitHub Issues**: [Report bugs or request features](https://github.com/cognizonline/cogniz-claude-code/issues)\n- **Discord**: Join our community server\n- **Email**: support@cogniz.online\n\n## Changelog\n\n**v1.0.0** (2025-01-25)\n- Initial public release\n- SessionStart, PostToolUse, UserPromptSubmit hooks\n- Project-based organization with auto-detection\n- Python and Shell script implementations\n- Comprehensive documentation and examples\n\n---\n\n**Built by [Cogniz Memory Platform](https://cogniz.online)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcognizonline%2Fclaude-memory-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcognizonline%2Fclaude-memory-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcognizonline%2Fclaude-memory-hooks/lists"}