원클릭으로
opengrok-cpp
Specialized patterns for navigating C++ codebases with OpenGrok MCP
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Specialized patterns for navigating C++ codebases with OpenGrok MCP
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use this skill whenever the user wants to search, navigate, or understand source code in a large codebase — even when they don't say "OpenGrok". Trigger for: finding where a function or class is defined, tracking where something is called or referenced, reading a remote source file, checking who last changed a line (blame/annotate), browsing a directory tree, exploring commit history, or comparing code across projects. Activate when the user says "search the codebase", "find where X is defined", "who changed this", "show me the source for", "look up that function", or mentions cross-referencing or OpenGrok by name. If the target code lives on a remote server or indexed repository rather than locally, this skill applies.
Use this skill when conducting a structured investigation into a bug, unknown module, or impact analysis using OpenGrok. Provides step-by-step methodology for systematic codebase investigation with memory-backed state management. Trigger when: diagnosing a bug with unknown root cause, exploring an unfamiliar module, tracing a call chain, or assessing the impact of a change.
Session lifecycle management for OpenGrok MCP investigations. Use this skill to understand how to start, maintain, and complete an OpenGrok session with proper memory bank state management. Trigger at session start when you know an investigation will span multiple turns, or when restoring a prior session.
| name | opengrok-cpp |
| description | Specialized patterns for navigating C++ codebases with OpenGrok MCP |
Specialized navigation patterns for C++ projects. Use alongside the opengrok skill
for general tool reference.
Use opengrok_get_symbol_context with include_header: true to fetch both the class
definition and its header file in one call:
{
"tool": "opengrok_get_symbol_context",
"arguments": {
"symbol": "ClassName",
"file_type": "cxx",
"include_header": true,
"context_lines": 25,
"max_refs": 10
}
}
Search for class definitions that inherit from a base class:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "class*:ClassName",
"search_type": "defs",
"file_type": "cxx",
"max_results": 20
}
}
Or use full-text search for explicit inheritance patterns:
{
"tool": "opengrok_search_and_read",
"arguments": {
"query": "class*: public ClassName",
"search_type": "full",
"file_type": "cxx",
"context_lines": 10,
"max_results": 15
}
}
Search for references to a base class method to find all overrides:
{
"tool": "opengrok_get_symbol_context",
"arguments": {
"symbol": "baseMethod",
"file_type": "cxx",
"max_refs": 25
}
}
Then search for the override keyword near method declarations in derived classes:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "override",
"search_type": "full",
"file_type": "cxx",
"max_results": 50
}
}
Templates are not indexed as definitions — use full-text search for instantiation patterns:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "ClassName<",
"search_type": "full",
"file_type": "cxx",
"max_results": 20
}
}
Find template specializations by searching for both the class name and angle brackets:
{
"tool": "opengrok_batch_search",
"arguments": {
"queries": [
{ "query": "ClassName", "search_type": "defs" },
{ "query": "template<>", "search_type": "full" }
],
"file_type": "cxx",
"max_results": 15
}
}
Locate template metaprogramming patterns by searching for common constructs:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "enable_if OR type_traits OR static_assert",
"search_type": "full",
"file_type": "cxx",
"max_results": 20
}
}
Look for includes of common TMP headers:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "#include <type_traits> OR #include <enable_if>",
"search_type": "full",
"file_type": "cxx",
"max_results": 10
}
}
Use opengrok_get_symbol_context to locate where a macro
is defined (it always returns both definitions and references):
{
"tool": "opengrok_get_symbol_context",
"arguments": {
"symbol": "MACRO_NAME",
"file_type": "cxx",
"include_header": true
}
}
Search for all references to the macro:
{
"tool": "opengrok_get_symbol_context",
"arguments": {
"symbol": "MACRO_NAME",
"file_type": "cxx",
"max_refs": 30
}
}
Find all uses of a preprocessor macro in conditional blocks:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "#ifdef MACRO_NAME OR #if defined(MACRO_NAME)",
"search_type": "full",
"file_type": "cxx",
"max_results": 25
}
}
Search for files that include a specific header:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "#include \"header.h\" OR #include <header.h>",
"search_type": "full",
"file_type": "cxx",
"max_results": 20
}
}
Find all files that include a target header by searching for the filename:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "target.h",
"search_type": "refs",
"file_type": "cxx",
"max_results": 30
}
}
Trace include chains using opengrok_batch_search recursively. Start with a header
and search for its includes, then search for includes of those files:
{
"tool": "opengrok_batch_search",
"arguments": {
"queries": [
{ "query": "#include \"module_a.h\"", "search_type": "full" },
{ "query": "#include \"module_b.h\"", "search_type": "full" },
{ "query": "#include \"module_c.h\"", "search_type": "full" }
],
"file_type": "cxx",
"max_results": 15
}
}
Use opengrok_get_compile_info to retrieve compiler flags, include paths, defines,
and language standard for a source file (requires local compile_commands.json):
{
"tool": "opengrok_get_compile_info",
"arguments": {
"project": "myproject",
"path": "src/main.cpp"
}
}
Returns -I include paths, -D defines, -std version, and full compiler flags.
Find the symbol definition that's missing by searching the definition index:
{
"tool": "opengrok_get_symbol_context",
"arguments": {
"symbol": "missingSymbol",
"file_type": "cxx"
}
}
Check if it's defined in an inline method or header-only library:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "missingSymbol",
"search_type": "full",
"file_type": "cxx",
"max_results": 20
}
}
Find the template definition and check for constraint violations:
{
"tool": "opengrok_get_symbol_context",
"arguments": {
"symbol": "TemplateClass",
"file_type": "cxx",
"include_header": true,
"context_lines": 30
}
}
Then search for enable_if constraints and static_assert in the template:
{
"tool": "opengrok_search_and_read",
"arguments": {
"query": "TemplateClass AND (enable_if OR static_assert)",
"search_type": "full",
"file_type": "cxx",
"context_lines": 15,
"max_results": 5
}
}
Search for the override keyword near method declarations to find missing overrides:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "override",
"search_type": "full",
"file_type": "cxx",
"max_results": 30
}
}
Or search for a method in the base class to find all where it should be overridden:
{
"tool": "opengrok_get_symbol_context",
"arguments": {
"symbol": "virtualMethod",
"file_type": "cxx",
"max_refs": 20
}
}
Search for using namespace declarations and check nested namespaces:
{
"tool": "opengrok_search_code",
"arguments": {
"query": "using namespace",
"search_type": "full",
"file_type": "cxx",
"max_results": 20
}
}
Find a specific symbol within a namespace:
{
"tool": "opengrok_get_symbol_context",
"arguments": {
"symbol": "namespace::ClassName",
"file_type": "cxx",
"include_header": true
}
}
Code Mode saves 75–95% tokens for complex investigations. Use opengrok_execute with
env.opengrok.* methods:
// Search definitions, references, and instantiations in one sandbox execution
const [defs, refs, instantiations] = env.opengrok.batchSearch([
{ query: "MyClass", searchType: "defs" },
{ query: "MyClass", searchType: "refs", maxResults: 50 },
{ query: "MyClass<", searchType: "full", maxResults: 30 }
]);
const locations = {
defined: defs.results[0]?.path,
referenced: refs.results.map(r => ({ path: r.path, lines: r.matches.map(m => m.lineNumber) })),
instantiated: instantiations.results.map(r => r.path)
};
return locations;
// Recursively map include relationships without leaving the sandbox
const getIncludes = (filePath, depth = 0, visited = new Set()) => {
if (depth > 5 || visited.has(filePath)) return [];
visited.add(filePath);
const content = env.opengrok.getFileContent('myproject', filePath);
const includePattern = /#include\s+["<]([^">\n]+)[">]/g;
const includes = [];
let match;
while ((match = includePattern.exec(content.content)) !== null) {
includes.push(match[1]);
}
return includes;
};
const graph = getIncludes('src/main.cpp');
return graph;
// Search for classes inheriting from a base interface
const results = env.opengrok.batchSearch([
{ query: "class*: public InterfaceName", searchType: "full", maxResults: 30 }
]);
const implementations = results[0].results.map(r => ({
path: r.path,
className: r.matches[0]?.lineContent
}));
return implementations;
file_type: cxx vs cppOpenGrok uses cxx for C++ files (not cpp). Always use file_type: "cxx" when
filtering to C++ code.
Template definitions are not indexed as defs entries — Ctags cannot instantiate
templates at index time. Use full-text search for template instantiation patterns
(e.g., ClassName<) instead of search_type: "defs".
Methods defined directly in class bodies (inline) live in headers, not .cpp files.
Always set include_header: true in opengrok_get_symbol_context for C/C++, and
remember to search .h/.hpp files when looking for implementations.
Symbols in anonymous namespaces won't appear in global refs — they're file-local. Scope searches to specific files when looking for anonymous namespace symbols, or broaden the full-text search to include the namespace scope.
opengrok_get_file_symbols will not list macro values or expansions — the indexer
only stores macro names. Use opengrok_get_symbol_context to find both macro
definitions and references in one call. For macro expansion
analysis, use full-text search or Code Mode to parse the preprocessed output.