SKILL.md
BibTeX Management Guide
A skill for maintaining clean, consistent, and complete BibTeX bibliography files. Covers formatting standards, deduplication, common errors, and automated cleanup workflows essential for LaTeX-based academic writing.
BibTeX Entry Standards
Required Fields by Entry Type
% Article in a journal
@article{smith2024deep,
author = {Smith, John A. and Doe, Jane B.},
title = {Deep Learning for Climate Prediction: A Comparative Study},
journal = {Nature Machine Intelligence},
year = {2024},
volume = {6},
number = {3},
pages = {234--248},
doi = {10.1038/s42256-024-00001-1}
}
% Conference proceedings
@inproceedings{lee2024attention,
author = {Lee, Wei and Chen, Li},
title = {Attention Mechanisms for Scientific Document Understanding},
booktitle = {Proceedings of the 62nd Annual Meeting of the ACL},
year = {2024},
pages = {1123--1135},
publisher = {Association for Computational Linguistics},
doi = {10.18653/v1/2024.acl-main.89}
}
% Book
@book{bishop2006pattern,
author = {Bishop, Christopher M.},
title = {Pattern Recognition and Machine Learning},
publisher = {Springer},
year = {2006},
isbn = {978-0387310732}
}
Automated BibTeX Cleanup
Deduplication
import re
from collections import defaultdict
def parse_bibtex_entries(bib_content: str) -> list[dict]:
"""
Parse a BibTeX file into structured entries.
"""
entries = []
pattern = r'@(\w+)\{([^,]+),\s*(.*?)\n\}'
matches = re.finditer(pattern, bib_content, re.DOTALL)
for match in matches:
entry = {
'type': match.group(1).lower(),
'key': match.group(2).strip(),
'raw': match.group(0),
'fields': {}
}
fields_str = match.group(3)
field_pattern = r'(\w+)\s*=\s*[{\"](.+?)[}\"]'
for field_match in re.finditer(field_pattern, fields_str, re.DOTALL):
entry['fields'][field_match.group(1).lower()] = field_match.group(2).strip()
entries.append(entry)
return entries
def deduplicate_bibtex(entries: list[dict]) -> dict:
"""
Find and remove duplicate BibTeX entries.
Deduplication strategy:
1. Exact DOI match
2. Fuzzy title match (normalized)
3. Author + year + first title word match
"""
seen_dois = {}
seen_titles = {}
duplicates = []
unique = []
for entry in entries:
doi = entry['fields'].get('doi', '').lower().strip()
title = entry['fields'].get('title', '').lower().strip()
title_normalized = re.sub(r'[^a-z0-9\s]', '', title)
is_duplicate = False
# Check DOI match
if doi and doi in seen_dois:
duplicates.append({
'entry': entry['key'],
'duplicate_of': seen_dois[doi],
'reason': 'same DOI'
})
is_duplicate = True
elif doi:
seen_dois[doi] = entry['key']
# Check title match
if not is_duplicate and title_normalized:
if title_normalized in seen_titles:
duplicates.append({
'entry': entry['key'],
'duplicate_of': seen_titles[title_normalized],
'reason': 'same title'
})
is_duplicate = True
else:
seen_titles[title_normalized] = entry['key']
if not is_duplicate:
unique.append(entry)
return {
'unique_entries': len(unique),
'duplicates_found': len(duplicates),
'duplicates': duplicates,
'entries': unique
}
